News for hackers. Stuff that matters.
Re:Asynchronous programming and cooperative multitasking by toolslive on Sunday February 10, 2019 @05:00AM (#19127127)
This is written from a closed (python) world perspective. Even in python you have other alternatives (stackless [0]). In statically typed functional programming languages, the monadic approach (still) is rather popular: f () >>= g can be read as follows, when (eventually) the function f produces a result, hand that result as an argument to the function g. Monads do have a cognitive overhead, but the type system prevents you from attempting to do silly things. ymmv

  [0] https://github.com/stackless-dev/stackless/wiki
Re:Asynchronous programming and cooperative multitasking by greglindahl on Sunday February 10, 2019 @11:42AM (#19128465)
Even in the python async/await world, you can get preemptable multitasking by adding in a few ProcessPoolExecutor threads. I've found this to be extremely effective in a web crawler: the main thread is 100% cooperative and does all of the network I/O on a single core, while cpu-hungry activities like webpage parsing are done by ProcessPoolExecutor processes on other cores. The code is pretty and I can fully use an entire server with what is conceptually a single crawler.

asyncio.create_subprocess_shell() is another way to get a preemptable thing in the Python async/await world.