replace sigint signal handler, with atexit, to let run in a thread
if there is merge conflict: final result example: https://github.com/shimondoodkin/zero/blob/main/zero/server.py#L106-L111
Hi @shimondoodkin thanks for the PR!
Can you please add tests for using threads? TIA
Codecov Report
Patch coverage: 50.00% and project coverage change: -10.41 :warning:
Comparison is base (
e2c69a9) 75.35% compared to head (a4964a6) 64.95%.
:exclamation: Current head a4964a6 differs from pull request most recent head 4accdec. Consider uploading reports for the commit 4accdec to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #21 +/- ##
===========================================
- Coverage 75.35% 64.95% -10.41%
===========================================
Files 12 12
Lines 349 351 +2
===========================================
- Hits 263 228 -35
- Misses 86 123 +37
| Impacted Files | Coverage Δ | |
|---|---|---|
| zero/server.py | 42.37% <50.00%> (-18.84%) |
:arrow_down: |
... and 2 files with indirect coverage changes
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Hi @shimondoodkin thanks for the PR!
Can you please add tests for using threads? TIA
maybe yes. i will look into it (if all ok it will be this week).
Hi @shimondoodkin just a gentle knock, if you have some time on this. I appreciate the work! :pray:
Hi @shimondoodkin thanks for the tests. I found some issues for server termination in the tests. I see you are trying to fix them, thanks for that! 🙌 But if you want you can ignore that. Just test for the threads should be enough. I am trying to fix them in this PR => https://github.com/Ananto30/zero/pull/28
Hi @shimondoodkin I have fixed the server close issue in this PR => https://github.com/Ananto30/zero/pull/28 (exactly these lines server.py#111, server.py#137 and making fixtures in specific folders tests/single_server/conftest.py#14, tests/multiple_servers/conftest.py#10)
So I already merged to main, if you rebase, you dont have to spend time on solving that (hopefully, same thing helps in thread)
here it returns value by reference if it works then it works. if there is a problem with references it returns None. seems on primitive values it returns the value in anyway.
https://github.com/shimondoodkin/zero/blob/replace-signal-handler-atexit/tests/server_test.py#L72
i was trying to solve the exit problem. using zmq pooling worked for me in another project and it exited ok nicely and avoided blocking in recv indefinitely. seems it exiting well when using sigint but not when using sigterm.
seems it is stuck in native module in socket.recv(). maybe zmq doesn't handle sigterm, maybe only sigint. or maybe sigterm is switched. maybe it is the reason why it is not working. could be that it is not calling the previous original signal sig term signal handler..
@shimondoodkin very good point! I have introduced polling for the sync client. For the async client, there are still some issues. And for the server, I haven't tried polling. Maybe I should.