1

Let's say that my (asyncio) workflow is like this:

  1. A = aiohttp.get(url_a) (with n retries and timeout of each retry)
  2. B = aiohttp.get(url_b) (with n retries and timeout of each retry)
  3. if I got A & B -> save to the database
  4. if I got A but not B -> impute B and save to the database
  5. if I got B but not A -> impute A and save to the database
  6. if I haven't got A nor B -> impute A, impute B, save to the database
  7. aiohttp.post(url_x) (A, B)

Basically, I am trying to get A and B, but I could end in 4 different situations: get A and B, get A but not B, get B but not A and cannot get anything. Anyway, after timeout, I must know what I have got and continue with imputing missing values (if any) and saving to the database. When I say imputing, it is oversimplified. Actually, I need some kind of branching, checking inputs and choosing branch (something like if). After the record is successfully saved to the database, A and B should be posted to url_x.

Is such workflow an use case for (py)transitions state machine? If so, is there any example that is a bit alike the scenario I have just described? As a novice to the state machine concept, I don't even know what states are here and what are transitions.

user3225309
  • 1,183
  • 3
  • 15
  • 31

0 Answers0