zero icon indicating copy to clipboard operation
zero copied to clipboard

replace sigint signal handler, with atexit, to let run in a thread

Open shimondoodkin opened this issue 3 years ago • 10 comments

shimondoodkin avatar Jan 28 '23 09:01 shimondoodkin

if there is merge conflict: final result example: https://github.com/shimondoodkin/zero/blob/main/zero/server.py#L106-L111

shimondoodkin avatar Jan 28 '23 09:01 shimondoodkin

Hi @shimondoodkin thanks for the PR!

Can you please add tests for using threads? TIA

Ananto30 avatar Jan 31 '23 09:01 Ananto30

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.

codecov[bot] avatar Jan 31 '23 09:01 codecov[bot]

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).

shimondoodkin avatar Jan 31 '23 09:01 shimondoodkin

Hi @shimondoodkin just a gentle knock, if you have some time on this. I appreciate the work! :pray:

Ananto30 avatar Mar 08 '23 10:03 Ananto30

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

Ananto30 avatar Mar 21 '23 19:03 Ananto30

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)

Ananto30 avatar Mar 23 '23 11:03 Ananto30

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

shimondoodkin avatar Mar 24 '23 01:03 shimondoodkin

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 avatar Mar 24 '23 02:03 shimondoodkin

@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.

Ananto30 avatar Mar 25 '23 12:03 Ananto30