Is this pythonic?

Chris Angelico rosuav at gmail.com
Thu Nov 24 06:06:13 EST 2016


On Thu, Nov 24, 2016 at 9:59 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Chris Angelico <rosuav at gmail.com>:
>
>> On Thu, Nov 24, 2016 at 7:39 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>>>  * Coroutines can be killed, threads cannot.
>>
>> Not strictly true. A coroutine can be abandoned at an await point, but
>> the currently-executed call is still going to complete (usually);
>
> I don't quite understand. Say you are awaiting on receiving bytes from a
> socket. That means there has been a nonblocking call to read(2),
> recvmsg(2) or equivalent that has returned EAGAIN. If you now abandon
> the coroutine, there is no resumption of the system call but the
> coroutine can finish instantaneously.

Is the read(2) still going to consume data from the pipe/socket? If
so, the operation is still going to continue, whether you use
coroutines or threads. If not, it would have been cancelled whether
you use coroutines or threads.

ChrisA



More information about the Python-list mailing list