-
Notifications
You must be signed in to change notification settings - Fork 761
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
Clarify documentation for teardown return from run_forever() #785
Comments
If I am understanding correctly, there is an edge case that is triggered when pressing the stop button in an IDE. I haven't used PyCharm lately so this could be an error that I never encountered. Could you try drafting a PR so that "False" is returned instead of "None" in this edge case? It should help me understand better how the edge case happens. A different low effort idea is to edit the docstring to mention that "None" is return in some edge cases, so that developers are aware of this edge case. |
@engn33r my explanation above was not very clear, my apologies. Here is a minimal example to demonstrate import signal
import websocket
if __name__ == '__main__':
def shutdown(*args):
print("close")
ws.close()
signal.signal(signal.SIGINT, shutdown)
ws = websocket.WebSocketApp("wss://example.com")
teardown = ws.run_forever()
print(teardown) If you pass The core issue here is the assumption that I've raised a PR (#788) to have The intended meaning of the name |
…s called (#788) * fix!: `WebSocketApp.run_forever()` returning `None` after `close()` is called BREAKING CHANGE: the return value of `WebSocketApp.run_forever()` will no longer return the (undocumented) `None` value. * fix(tests): replace the defunct `wss://stream.meetup.com/2/rsvps` with `wss://api.bitfinex.com/ws/2` in several tests * test: added two new local server tests to cover the changes in #785 * Remove newline to fix lint error
The doc-comment in
run_forever
says:This doesn't cover are the cases where
run_forever
returnsNone
.One case is on signal
SIGTERM
which causeskeep_running
to becomeFalse
and therefore SSLDispatcher.read returnsNone
. Pressing the stop button in PyCharm will trigger this.I think the intention here is to allow the caller to differentiate between a graceful and non-graceful exit. Given that it may be sensible to have
run_forever
always return eitherFalse
orTrue
and have bothSIGINT
(i.e.KeyboardInterrupt
exception) and other non-exceptional status (i.e.SIGTERM
) returnFalse
.The text was updated successfully, but these errors were encountered: