Saimadhav Heblikar <saimadhavhebli...@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
surprisingly messy).


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to