Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling the situations when _rsock is None #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Shmuma
Copy link

@Shmuma Shmuma commented Jun 19, 2018

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'

@pgiri
Copy link
Owner

pgiri commented Jun 19, 2018

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

@Shmuma
Copy link
Author

Shmuma commented Jun 19, 2018

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.

@pgiri
Copy link
Owner

pgiri commented Jun 20, 2018

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.

@pgiri
Copy link
Owner

pgiri commented Jun 20, 2018

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.

@Shmuma
Copy link
Author

Shmuma commented Jun 20, 2018

Cool! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants