[Python-ideas] How the heck does async/await work in Python 3.5
wjun77 at gmail.com
Wed Feb 24 19:40:44 EST 2016
I think this is possible if I understand what happens under the hood.
I wonder how event loop and async io functions such as
asyncio.open_connection cooperate to do async io in one thread. Maybe it
exploits low-level details and is OS or even device specific. I think I
should take a look at the source code when I have time.
2016-02-25 5:00 GMT+08:00 Gregory Ewing <greg.ewing at canterbury.ac.nz>:
> 王珺 wrote:
>> Suppose io_operation() takes 3 seconds, then how can I write something
>> future = io_operation()
>> that print 'Start' immediately and the result of io_operation() 3 seconds
> Yes, Python can do this, but you probably need to use real
> threads. The only exception would be if io_operation() were
> something you could fire off with a single system call that's
> guaranteed not to block, and then wait for the result later.
> Opportunities for things like that are rare in unix.
> (Windows might be different, I'm not sure.)
More information about the Python-list