Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@craigds
Copy link
Contributor

@craigds craigds commented Aug 31, 2023

In 9adcd7e a change was made to make the workhorse process into a session leader. This appears to have been done in order to set the process group ID of the workhorse so that it can be killed easily along with its descendants when Worker.kill_horse() is called.

However, setsid is overkill for this purpose; it sets not only the process group ID but also the session ID. This can cause issues for user jobs which may rely on session IDs being less-than-unique for arbitrary reasons.

This change switches to setpgrp; this sets the process group ID so that the workhorse and its descendants can be killed without changing the session ID.

@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (0f4d041) 93.61% compared to head (143baa2) 93.61%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1970   +/-   ##
=======================================
  Coverage   93.61%   93.61%           
=======================================
  Files          28       28           
  Lines        3757     3757           
=======================================
  Hits         3517     3517           
  Misses        240      240           
Files Changed Coverage Δ
rq/worker.py 88.50% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

In 9adcd7e a change was made to make
the workhorse process into a session leader. This appears to have been
done in order to set the process group ID of the workhorse so that it
can be killed easily along with its descendants when
`Worker.kill_horse()` is called.

However, `setsid` is overkill for this purpose; it sets not only the
process group ID but also the session ID. This can cause issues for user
jobs which may rely on session IDs being less-than-unique for arbitrary
reasons.

This change switches to `setpgrp`; this sets the process group ID so
that the workhorse and its descendants can be killed *without* changing
the session ID.
@selwin
Copy link
Collaborator

selwin commented Sep 9, 2023

@craigds would this change negatively affect use cases outlined in the original PR? #1348

@craigds
Copy link
Contributor Author

craigds commented Sep 9, 2023

no - setpgrp still sets the process group ID, which is all that is needed for killing a process and all of its descendents.

setsid not only sets the process group but also the session, which is a more powerful concept which isn't actually required for the purpose of killing related processes

@selwin selwin merged commit a044248 into rq:master Sep 23, 2023
@selwin
Copy link
Collaborator

selwin commented Sep 23, 2023

Thanks!

@craigds craigds deleted the dont-use-setsid branch October 11, 2024 00:56
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.

2 participants