Not covered: Niceties of asynchrony, when threads run truly concurrently (it’s complicated, but you need ’em often even for non-concurrent stuff so deal with it), when evented poll systems are truly asynchronous (never, but it doesn’t matter).
TODO: cover uvloop.
tools for async-style coroutine concurrency
Modern python async-style stuff.
tl;dr Use the event loop from tornado or pyzmq. These non-thread IO things are very easy and comparatively well-documented. And they work with the new python 3 async style. You can use them to farm off heavy computation to other threaded nightmare hell farms or whatever, and they already work right now.
UPDATE: actually raw asyncio is getting civilized these days, might be worth using. But there is a complicated relationship between the verious bits. G’luck.
Here are some ingredients that might make these work better:
rxexists for python as rxpy and is tornado compatible.
terminado provides a terminal for tornado, for quick and dirty interaction.
This feels over-engineered to me, but looks easy for some common cases.
Alternative async ecosystems: curio etc
Curio is a library for performing concurrent I/O and common system programming tasks such as launching subprocesses and farming work out to thread and process pools. It uses Python coroutines and the explicit async/await syntax introduced in Python 3.5. Its programming model is based on cooperative multitasking and existing programming abstractions such as threads, sockets, files, subprocesses, locks, and queues. You’ll find it to be small and fast.
The essay that explains why there is a different synchronous ecosystem: Nathaniel J. Smith , Some thoughts on asynchronous API design in a post-async/await world
Curio doesn’t have much in the way of tooling yet. e.g. for HTTP requests you might use curequests or asks. for a server, you might import a raw HTTP2 library and go bareback
Check datasette for an example of integrating threading loops (
Sometimes you need it.
But I don’t have much to say, and am not expert.
For threaded and multi-proc concurrency you sometimes need simple shared variables. Here is, e.g. how you do counters.