Question about asyncio doc example
marko at pacujo.net
Thu Jul 24 07:54:07 CEST 2014
Saimadhav Heblikar <saimadhavheblikar at gmail.com>:
> For situations where I dont really know how long a function is going
> to take(say waiting for user input or a network operation), I am
> better off using callbacks than "yield from asyncio.sleep()". Is my
> understanding correct?
If you choose the coroutine style of programming, you wouldn't normally
use callbacks. Instead, you would "yield from" any blocking event. There
are coroutine equivalents for locking, network I/O, multiplexing etc.
The callback style encodes the state in a variable. The coroutine style
(which closely resembles multithreading), encodes the state in the code
itself. Both styles can easily become really messy (because reality is
More information about the Python-list