You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 23, 2017. It is now read-only.
Here's the snippet, that replicates the issue. I stomped upon this in normal TCP sockets, so sockpair is not the issue.
importasyncioimportsocketimportsslimportsysimportthreadingcontext=ssl.create_default_context()
rsock, wsock=socket.socketpair()
defreader(sock):
data=sock.recv(4)
print("RCV", data)
sock.close()
t=threading.Thread(target=reader, args=(rsock, ))
t.start()
try:
ifsys.argv[1] =='sync':
# The blocking example works OK. Exits right awaysock=context.wrap_socket(
wsock,
server_hostname="localhost",
)
print("Connected")
elifsys.argv[1] =="async":
# Non blocking call exampleasyncdefconnect(loop):
reader, writer=awaitasyncio.open_connection(
sock=wsock, ssl=context, loop=loop,
server_hostname="localhost")
print("Connected Async")
loop=asyncio.get_event_loop()
loop.run_until_complete(loop.create_task(connect(loop)))
finally:
wsock.close()
t.join()
The idea is, that the other end is not an SSL socket, but rather some plain protocol, that reads size (lets say 4 bytes) and closes the socket, as size is inappropriate.
Blocking (test.py sync) socket works as expected raising ConnectionResetError
Async (test.py async) example blocks forever
Version:
Python 3.5.2 (default, Jul 17 2016, 00:00:00)
[GCC 4.8.4] on linux