Asynchronous programming

Marko Rauhamaa marko at pacujo.net
Thu Aug 11 06:43:10 EDT 2016


Chris Angelico <rosuav at gmail.com>:

> On Thu, Aug 11, 2016 at 5:55 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> My favorite asynchronous development model is the "callback hell," where
>> each cell of the state/event matrix is represented by a method (or at
>> least a switch case in C) and each state has an explicit name in the
>> source code. The resulting code is still hard to read and hard to get
>> right, but that complexity is unavoidable because reality just is that
>> complex.
>
> Wow. Are you for real, or are you trolling us? You actually *enjoy*
> callback hell?
>
> Give me yield-based asyncio any day.

To me, the key is that the code should closely mirror the classic FSM
formalisms:

  <URL: http://images.slideplayer.com/14/4228155/slides/slide_21.jpg>

  <URL: http://www.detewe.ru/q931/image/10.gif>

  <URL: https://people.ece.cornell.edu/land/courses/ece4760/FinalPr
  ojects/s2011/pss83/Website/Time%20System/instruction_matrix.PNG>


It *would* be possible to write asyncio code the same way where you
would represent states as asyncs and express state transitions as:

    await self.ESTABLISHING()

Alas, that would lead to unlimited async recursion, which, I'm pretty
sure, would overflow Python's execution stack.


Marko



More information about the Python-list mailing list