Alisue Lambda <[email protected]> added the comment:
I've found an workaround. The point is that 'with s' should be included in a
coroutine which will be timed-out.
import asyncio
import socket
ADDR = ('10.0.2.1', 22)
async def check(loop):
s = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
s.setblocking(False)
with s:
await loop.sock_connect(s, ADDR)
async def test(loop):
try:
await asyncio.wait_for(
check(loop),
timeout=3,
loop=loop,
)
except Exception as e:
print('Fail: %s' % e)
else:
print('Success')
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33350>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com