Message260596
If your event loop supports it, maybe you could use add_reader() etc as a workaround (roughly based off a different function of my own; this version completely untested):
async def sock_recvfrom(nonblocking_sock, *pos, loop, **kw):
while True:
try:
return nonblocking_sock.recvfrom(*pos, **kw)
except BlockingIOError:
future = Future(loop=loop)
loop.add_reader(nonblocking_sock.fileno(), future.set_result, None)
try:
await future
finally:
loop.remove_reader(nonblocking_sock.fileno())
I’m not very experienced with asyncio, but I imagine having general-purpose loop.wait_readable(file_descriptor) etc methods would make writing these kind of functions easier. |
|
Date |
User |
Action |
Args |
2016-02-21 07:41:03 | martin.panter | set | recipients:
+ martin.panter, gvanrossum, vstinner, yselivanov, sbstp |
2016-02-21 07:41:02 | martin.panter | set | messageid: <1456040462.94.0.273139833972.issue26395@psf.upfronthosting.co.za> |
2016-02-21 07:41:02 | martin.panter | link | issue26395 messages |
2016-02-21 07:41:02 | martin.panter | create | |
|