Steven D'Aprano <steve+pyt...@pearwood.info> writes:
>>         await asyncio.sleep(0.2)  # pretend to do some real work
> That is *awesome*. Thank you for the example!

Keep in mind that the above basically takes the task off the list of
runnables for 0.2 seconds, so it sits doing nothing and doesn't
interfere with other tasks running.  In the case where you're doing
actual computation, you want to yield (await) much more often than 0.2
sec, so other tasks can stay responsive.  This is cooperative
multitasking, where each task has to be nice to the others, in contrast
with preemptive multitasking where the task switches happen behind the
scenes.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to