Message315709
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)) |
|
Date |
User |
Action |
Args |
2018-04-24 17:21:25 | Alisue Lambda | set | recipients:
+ Alisue Lambda, asvetlov, yselivanov |
2018-04-24 17:21:25 | Alisue Lambda | set | messageid: <1524590485.25.0.682650639539.issue33350@psf.upfronthosting.co.za> |
2018-04-24 17:21:25 | Alisue Lambda | link | issue33350 messages |
2018-04-24 17:21:25 | Alisue Lambda | create | |
|