Last active
August 29, 2015 14:17
-
-
Save kernel0/400d040dcf2734457123 to your computer and use it in GitHub Desktop.
issue : sock_accept of ProactorEventLoop missed OSError 64 (ERROR_NETNAME_DELETED)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dummy client | |
import asyncio | |
import logging | |
import socket | |
ip = "127.0.0.1" | |
@asyncio.coroutine | |
def test_conn(loop): | |
try: | |
c = socket.socket() | |
c.setblocking(False) | |
yield from loop.sock_connect(c, (ip, 9090)) | |
logging.info("socket connected") | |
except OSError: | |
logging.info("socket disconnected") | |
def main(): | |
l = logging.getLogger() | |
l.setLevel(logging.INFO) | |
loop = asyncio.ProactorEventLoop() | |
asyncio.set_event_loop(loop) | |
for i in range(5000): | |
loop.create_task(test_conn(loop)) | |
loop.run_forever() | |
loop.close() | |
if __name__ == "__main__": | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
import os | |
import socket | |
ip = "127.0.0.1" | |
@asyncio.coroutine | |
def accept(loop, s): | |
while True: | |
try: | |
yield from loop.sock_accept(s) | |
except asyncio.CancelledError: | |
logging.info("on socket accept failed - cancelled error") | |
except OSError: | |
logging.info("on socket accept failed - os error ") | |
else: | |
logging.info("on socket accept") | |
def main(): | |
l = logging.getLogger() | |
l.setLevel(logging.INFO) | |
loop = asyncio.ProactorEventLoop() | |
asyncio.set_event_loop(loop) | |
s = socket.socket() | |
s.setblocking(False) | |
s.bind((ip, 9090)) | |
s.listen(500) | |
loop.run_until_complete(accept(loop, s)) | |
loop.close() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment