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

AttributeError on pymorse close() #557

Closed
pronobis opened this issue Aug 20, 2014 · 6 comments
Closed

AttributeError on pymorse close() #557

pronobis opened this issue Aug 20, 2014 · 6 comments

Comments

@pronobis
Copy link
Contributor

When running close() as shown below, I get the exception attached. This is invoked when the roslaunch running my morse and this pymorse app is killed, so it is likely that morse itself is dead by then. Still, it should be possible to close pymorse without error.

            with pymorse.Morse() as morse:
                # Start the node
                node = Node(morse)
                node.spin()
                # Close pymorse
                morse.close(cancel_async_services=True)
Service call failed: unable to connect to service: [Errno 4] Interrupted system call
Traceback (most recent call last):
    morse.close(cancel_async_services=True)
  File "/opt/sara_morse/lib/python3.3/site-packages/pymorse/pymorse.py", line 638, in __exit__
    self.close()
  File "/opt/sara_morse/lib/python3.3/site-packages/pymorse/pymorse.py", line 586, in close
    Morse._asyncore_thread.join(TIMEOUT)
AttributeError: 'NoneType' object has no attribute 'join'
@PierrickKoch
Copy link
Member

Could you test with 1ecd5a1
hopefully it will solve your problem :-)

@pronobis
Copy link
Contributor Author

Well, now I get the following exception instead:

Traceback (most recent call last):
    morse.close(cancel_async_services=True)
  File "/opt/sara_morse/lib/python3.3/site-packages/pymorse/pymorse.py", line 648, in __exit__
    self.close()
  File "/opt/sara_morse/lib/python3.3/site-packages/pymorse/pymorse.py", line 595, in close
    Morse._asyncore_thread.syncstop(TIMEOUT)
AttributeError: 'NoneType' object has no attribute 'syncstop'

@adegroote
Copy link
Contributor

The call to close is unnecessarily, as it is basically call at the end of the with scope (its is the main goal of the with syntax :)).

Otherwise, the issue is that Morse._asyncore_thread is set to None line 597, and accessed again in the second call to close.

@pronobis
Copy link
Contributor Author

Without that line, pymorse will actually never quit. I was looking for a workaround to that problem hoping that adding cancel_async_services=True will actually kill the async services that block pymorse from closing.

@adegroote
Copy link
Contributor

Could you test df8d098 please ?

@pronobis
Copy link
Contributor Author

pronobis commented Sep 1, 2014

That did the trick as far as I can see.

PierrickKoch pushed a commit to PierrickKoch/morse that referenced this issue Dec 18, 2014
If we call close more than once, the thread is already dead, so just do
nothing in this case.
Fix morse-simulator#557
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

No branches or pull requests

3 participants