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

Adding logic to ensure teardown is called before run_forever exits, otherwise resources like the ping thread are leaked. #918

Merged
merged 4 commits into from
Jun 17, 2023

Conversation

QuinnDamerell
Copy link
Contributor

Fixes issue #917, see my description there on how it's possible to return from run_forever without calling teardown. There might be other ways as well, so my solution here is a good way to ensure it's called.

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage: 93.33% and project coverage change: +0.31 🎉

Comparison is base (eda6724) 83.45% compared to head (3a487eb) 83.77%.

❗ Current head 3a487eb differs from pull request most recent head 0449bd6. Consider uploading reports for the commit 0449bd6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #918      +/-   ##
==========================================
+ Coverage   83.45%   83.77%   +0.31%     
==========================================
  Files          13       13              
  Lines        1360     1368       +8     
  Branches      257      259       +2     
==========================================
+ Hits         1135     1146      +11     
+ Misses        149      147       -2     
+ Partials       76       75       -1     
Impacted Files Coverage Δ
websocket/_app.py 81.85% <93.33%> (+1.77%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@wormsik
Copy link

wormsik commented Jun 14, 2023

Great work @QuinnDamerell ! Do you think it solves also #612 ? From the quick look at the code I guess it should as on_close is executed inside teardown method.

@engn33r
Copy link
Collaborator

engn33r commented Jun 14, 2023

Excellent work identifying the specific code path that causes this issue. I will request @bubbleboy14 to give a final comment before I merge this and create a new 1.6.0 minor release, but this PR looks like a very welcome upgrade.

I tested this updated code on the two problematic code examples where on_close was not getting triggered and this solves them 👍
https://websocket-client.readthedocs.io/en/v1.5.2/threading.html#possible-issues-with-threading

@bubbleboy14
Copy link
Collaborator

Great job @QuinnDamerell ! These look like excellent changes, and they pass my tests.

I say go for it!

@QuinnDamerell
Copy link
Contributor Author

@engn33r, no pressure, but do you have any timeline on when this change might happen? I really want to pull it into my PY app, because I have quite a few users who hit this.

I'm happy to help if you need any assistance in testing or whatnot to get it in!

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

4 participants