Asynchronous programming

Paul Rubin no.email at nospam.invalid
Fri Aug 12 00:53:52 EDT 2016


Steven D'Aprano <steve+python at pearwood.info> writes:
> How do I write work() so that it cooperatively multi-tasks with other ...
> threads? processes? what the hell do we call these things? What does this
> example become in the asynchronous world?

If it's heavily computational then you have to yield to the scheduler
frequently so that other tasks have a chance to run.  So if your 0.2
second computation involves 100 iterations of something, you could yield
once per iteration (every 2 msec).



More information about the Python-list mailing list