How the heck does async/await work in Python 3.5

Paul Rubin no.email at nospam.invalid
Sun Feb 21 02:34:49 EST 2016


Steven D'Aprano <steve at pearwood.info> writes:
> "But frankly the stuff I'm seeing in this thread makes me sad for
> *literally every programming language in existence except for Erlang
> and maybe one or two others*, which altogether about six people use in
> total..."

Erlang microtasks are more a matter of the runtime environment than the
language.  It might be possible to have something like it in PyPy.

Other languages typically do concurrency with something like:

  1. threads - various hazards that can be avoided if you're careful
  2. callback chaining like in node.js - gets messy if the program
     is complicated, but conceptually simple
  3. explicit state machines with something like libevent in C --
     same as #2, simple but tedious
  4. lightweight threads/tasks like in GHC and Erlang -- very nice though
     requires a sophisticated runtime system
  5. cooperative multasking (small RTOS's, Forth, etc): simple, but
     apparently bug-prone when the program gets complicated

Python's async stuff seems to combine various of the above approaches
and (while I'm not saying it's objectively bad) the experiences I've had
with it so far have been confusing and unpleasant.  I do want to put
some effort into understanding asyncio, but so far threads have worked
ok for me.

OK Web Server (uses a separate C++ process for each page on the site)
looked straightforward and fast, though makes some architectural
impositions.

http://seastar-project.org/ seems interesting but I don't understand it
at the moment.


More information about the Python-list mailing list