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

client abandon logic and debug #17

Merged
merged 3 commits into from Feb 8, 2017
Merged

client abandon logic and debug #17

merged 3 commits into from Feb 8, 2017

Conversation

willmcgugan
Copy link
Contributor

@willmcgugan willmcgugan commented Feb 8, 2017

What this PR solves

  • Fix bugs on reconnect.

How it is done

  • removes any references to manager object when a m2m client is discarded.

What to look out for

  • Bugs

Screenshots (if appropriate)

Review

  • Ready for review

@@ -208,10 +207,14 @@ def unhandled_error(self, error):
# ws4py calls this with any socket errors
# Doesn't matter what the socket error is; connection is fubar.
log.error('error in WSApp: %s', error)
# Can't terminate here
# Trick the server in to exiting
self.server_terminated = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't call terminate. It doesn't look like that was intended to be a part of the public interface.

There is a close method, which attempts to send a websocket close frame. That wont work if the connection it fubar.

The server_terminated boolean exists the main loop. Its undocumented, a bit shitty, but it seems the only way to avoid tracebacks.

@@ -310,6 +313,16 @@ def connect(self, wait=True, timeout=None):
return self.wait_ready(timeout=timeout)
return None

def abandon(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset everything so this object won't process any packets nor block. To fix suspected thread not closing.

@@ -118,27 +127,35 @@ def run(self):

while 1:
# Get the identity, and tell the server about it
log.debug('1')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive these debug lines for now. I'll keep them in until we're more confident in the logic.

self.manager.on_client_close()

def abandon(self):
self._manager = None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Un-bind the manager, so there is no chance of some method being called from a hook from a dying thread.

@willmcgugan willmcgugan merged commit b5bf6b8 into master Feb 8, 2017
@willmcgugan willmcgugan deleted the fudge branch February 8, 2017 18:02
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.

None yet

2 participants