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

Disables siginterrupt for SIGUSR1 #1844

Merged
merged 1 commit into from
Sep 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions luigi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def __init__(self, scheduler=None, worker_id=None, worker_processes=1, assistant
if not self._config.no_install_shutdown_handler:
try:
signal.signal(signal.SIGUSR1, self.handle_interrupt)
signal.siginterrupt(signal.SIGUSR1, False)
except AttributeError:
pass

Expand Down
20 changes: 20 additions & 0 deletions test/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ def test_stop_getting_new_work(self):
self.w.run()
self.assertFalse(d.complete())

@mock.patch('luigi.worker.signal')
def test_signal_interrupt_disabled(self, worker_signal):
w = Worker(scheduler=self.sch)
worker_signal.signal.assert_called_once_with(worker_signal.SIGUSR1, w.handle_interrupt)
worker_signal.siginterrupt.assert_called_once_with(worker_signal.SIGUSR1, False)

@mock.patch('luigi.worker.signal')
def test_signal_interrupt_not_disabled_without_shutdown_handler(self, worker_signal):
Worker(scheduler=self.sch, no_install_shutdown_handler=True)
self.assertEqual(0, worker_signal.signal.call_count)
self.assertEqual(0, worker_signal.siginterrupt.call_count)

@mock.patch('luigi.worker.signal')
def test_signal_interrupt_ok_to_not_exist(self, worker_signal):
worker_signal.siginterrupt.side_effect = AttributeError
w = Worker(scheduler=self.sch) # may fail due to the AttributeError

# we still register the handler when the siginterrupt disable fails
worker_signal.signal.assert_called_once_with(worker_signal.SIGUSR1, w.handle_interrupt)

def test_disabled_shutdown_hook(self):
w = Worker(scheduler=self.sch, keep_alive=True, no_install_shutdown_handler=True)
with w:
Expand Down