pycos
pycos copied to clipboard
Handling the situations when _rsock is None
Hi!
Getting this error on program termination:
Traceback (most recent call last):
File "C:\Users\maxl\Anaconda3\envs\nips_run2\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Users\maxl\Anaconda3\envs\nips_run2\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "c:\users\maxl\work\personal\tmp\pycos\py3\pycos\__init__.py", line 3911, in _schedule
self._notifier.terminate()
File "c:\users\maxl\work\personal\tmp\pycos\py3\pycos\__init__.py", line 1885, in terminate
setblocking(True)
File "c:\users\maxl\work\personal\tmp\pycos\py3\pycos\__init__.py", line 264, in setblocking
self._rsock.setblocking(1)
AttributeError: 'NoneType' object has no attribute 'setblocking'
Is it possible to try following patch? I am trying to understand what socket is left behind in an inconsistent state (closed but in notifier). (I thought, as mentioned in commit log, this problem occurs with IOCP notifier, but apparently in your case 'select' notifier is used.) terminate.txt
Sure, the output of my program (which is just trivial netpycos client):
$ python adhoc/pycos/t1.py 2018-06-19 21:18:44 pycos - Could not load pywin32 for I/O Completion Ports; using inefficient polling for sockets 2018-06-19 21:18:44 pycos - version 4.7.0 with select I/O notifier 2018-06-19 21:18:44 pycos - version 4.7.0 with select I/O notifier 2018-06-19 21:18:45 pycos - TCP server "maxl-lt" @ 127.0.0.1:9705 2018-06-19 21:18:45 pycos - UDP server @ :9705 !server_task/[email protected]:9705 2018-06-19 21:18:48 pycos - cmd rsock: 776 2018-06-19 21:18:48 pycos - sockets left behding: 1 2018-06-19 21:18:48 pycos - socket 776 is already closed?
But the funny thing is: I cannot longer reproduce the issue with _rsock to be None :). I've tried on master branch, first issue (udp bind) is still there, but _rsock is now properly handled.
The fix for _rsock check is already in terminate, so it didn't cause crash. The line 'socket 776 is already closed?' is the culprit! However, this is not really a problem to worry about - it is an internal socket (used for interrupting scheduler).
BTW (as the log mentions) 'select' notifier is not efficient; you may want to install pywin32 to use IOCP notifier.
I was able to figure out what is causing _rsock to be None for cmd_rsock and fixed it. Now there is no need for explicit check for _rsock being not None in 'terminate' method (as done couple of commits ago), but for now I am leaving it in as this is done at the end so won't cause performance loss.
Cool! Thanks!