-
Notifications
You must be signed in to change notification settings - Fork 257
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
Flush the merge-wait queue on SIGUSR2 #1406
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,6 +210,8 @@ def __init__( | |
# empty. | ||
self._merge_wait_scheduled = [] | ||
|
||
self._flush_merge_wait_queue = False | ||
|
||
# Holds system packages and their deep runtime dependencies. Before | ||
# being merged, these packages go to merge_wait_queue, to be merged | ||
# when no other packages are building. | ||
|
@@ -1170,12 +1172,16 @@ def sighandler(signum, frame): | |
self.terminate() | ||
received_signal.append(128 + signum) | ||
|
||
def sigusr2handler(signum, frame): | ||
self._flush_merge_wait_queue = True | ||
|
||
earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler) | ||
earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler) | ||
earlier_sigcont_handler = signal.signal( | ||
signal.SIGCONT, self._sigcont_handler | ||
) | ||
signal.siginterrupt(signal.SIGCONT, False) | ||
earlier_sigusr2_handler = signal.signal(signal.SIGUSR2, sigusr2handler) | ||
|
||
try: | ||
rval = self._merge() | ||
|
@@ -1193,6 +1199,10 @@ def sighandler(signum, frame): | |
signal.signal(signal.SIGCONT, earlier_sigcont_handler) | ||
else: | ||
signal.signal(signal.SIGCONT, signal.SIG_DFL) | ||
if earlier_sigusr2_handler is not None: | ||
signal.signal(signal.SIGUSR2, earlier_sigusr2_handler) | ||
else: | ||
signal.signal(signal.SIGUSR2, signal.SIG_DFL) | ||
|
||
self._termination_check() | ||
if received_signal: | ||
|
@@ -1809,11 +1819,16 @@ def _schedule_tasks(self): | |
# special packages and we want to ensure that | ||
# parallel-install does not cause more than one of | ||
# them to install at the same time. | ||
if ( | ||
self._merge_wait_queue | ||
and not self._jobs | ||
and not self._task_queues.merge | ||
if self._merge_wait_queue and ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be nice as a variable instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I understand. "This" being There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the whole expression is pretty icky over multiple lines (although this is partly Black's fault). |
||
(not self._jobs and not self._task_queues.merge) | ||
or self._flush_merge_wait_queue | ||
): | ||
if self._flush_merge_wait_queue: | ||
self._status_msg( | ||
"Manual flush of the merge-wait queue requested (e.g., via SIGUSR2)" | ||
) | ||
self._flush_merge_wait_queue = False | ||
|
||
while self._merge_wait_queue: | ||
# If we added non-system packages to the merge queue in a | ||
# previous iteration of this loop, then for system packages we | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do this now, but I wonder if we could do bette rwith this with a context manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require creating a custom context manager class for signals, right?