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

fix: worker hangs sometimes #162

Merged
merged 4 commits into from
Jul 8, 2023

Conversation

Sobes76rus
Copy link
Contributor

@Sobes76rus Sobes76rus commented Jul 5, 2023

issues: #63 #81

child process inherits signal handlers from parent

the problem is that the terminate signal was triggered before the signal handler of the child process was set, we must set it immediately after the process starts

and I suggest telling the parent process that the worker is ready before the parent continues with the event queue.
or at least wait a while for the worker process to set the signal handler
or we can handle it in parent signal handler, and raise an error if it is not a main process

Copy link
Member

@s3rius s3rius left a comment

Choose a reason for hiding this comment

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

Actually good suggestions. Can you implement these?

I would implement it using multiprocessing Queue. Since we know how many workers we would like to have, so we can just wait for n messages from this queue, where n is the number of worker processes.

taskiq/cli/worker/process_manager.py Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #162 (dc9acb6) into develop (e66f3aa) will increase coverage by 2.44%.
The diff coverage is 76.47%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff             @@
##           develop     #162      +/-   ##
===========================================
+ Coverage    67.62%   70.06%   +2.44%     
===========================================
  Files           37       42       +5     
  Lines          942     1313     +371     
===========================================
+ Hits           637      920     +283     
- Misses         305      393      +88     
Impacted Files Coverage Δ
taskiq/abc/middleware.py 100.00% <ø> (ø)
taskiq/abc/result_backend.py 100.00% <ø> (ø)
taskiq/cli/scheduler/run.py 0.00% <0.00%> (ø)
taskiq/cli/watcher.py 0.00% <ø> (ø)
taskiq/cli/worker/log_collector.py 100.00% <ø> (ø)
taskiq/cli/worker/process_manager.py 0.00% <0.00%> (ø)
taskiq/cli/worker/run.py 0.00% <0.00%> (ø)
taskiq/events.py 100.00% <ø> (ø)
taskiq/receiver/params_parser.py 96.87% <ø> (ø)
taskiq/result_backends/dummy.py 100.00% <ø> (ø)
... and 23 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Sobes76rus
Copy link
Contributor Author

Sobes76rus commented Jul 5, 2023

OK, I did it through multiprocess.Event.

@Sobes76rus Sobes76rus requested a review from s3rius July 5, 2023 15:13
@Sobes76rus Sobes76rus changed the title fix/worker hangs sometimes fix: worker hangs sometimes Jul 5, 2023
Copy link
Member

@s3rius s3rius left a comment

Choose a reason for hiding this comment

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

I think it's great. Thank you.

@s3rius s3rius merged commit d8699d5 into taskiq-python:develop Jul 8, 2023
@Sobes76rus Sobes76rus deleted the fix/worker-hangs branch July 8, 2023 22:26
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.

3 participants