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

refactor the control loop and handle sigterm #65

Merged
merged 21 commits into from
Feb 18, 2020
Merged

Conversation

mmerickel
Copy link
Member

@mmerickel mmerickel commented Feb 15, 2020

fixes #64
fixes #63

@mmerickel mmerickel marked this pull request as ready for review February 16, 2020 17:35
@@ -184,10 +180,6 @@ def send(self, value):
self._write_packet(data)
return len(data) + self._packet_len.size

def recv(self, timeout=None):
packet = self.reader_queue.get(block=True, timeout=timeout)
return packet
Copy link
Member Author

Choose a reason for hiding this comment

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

got rid of the reader queue here and instead just invoke a callback letting the owner of the pipe handle packets how they wish (using a deque, notify the control pipe, etc)

src/hupper/ipc.py Outdated Show resolved Hide resolved

def _signal_sighup(self, signum, frame):
self.logger.info('Received SIGHUP, triggering a reload.')
self.monitor.set_changed()
Copy link
Member Author

Choose a reason for hiding this comment

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

this old version was acquiring locks in the handler - now we just write to the control pipe

@@ -61,7 +61,7 @@ def is_alive(self):

def stop(self):
if self.is_alive():
self.process.terminate()
self.process.kill()
Copy link
Member Author

Choose a reason for hiding this comment

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

hupper now catches SIGTERM so instead we want to just SIGKILL in the test suite once we're done with the test

worker.wait(shutdown_interval)
elif signal == ControlSignal.SIGCHLD:
if not worker.is_alive():
break
Copy link
Member Author

Choose a reason for hiding this comment

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

currently on windows SIGCHLD will not occur, but it's not a big deal because we have an open pipe with the child. When the child dies, the pipe is closed and we emit a WORKER_COMMAND with a None packet and we're able to exit pretty quickly via the if cmd is None check above.

mmerickel added a commit that referenced this pull request Feb 18, 2020
digitalresistor and others added 6 commits February 18, 2020 00:22
This way we make sure that when the other thread goes to read
self.monitor.is_changed it is actually set, especially if for some
reason sending the "signal" down the pipe causes the read to wakeup
before the thread finishes processing.
This reverts commit fbf8ab4.
@mmerickel mmerickel merged commit 3e516ad into master Feb 18, 2020
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.

Hupper does not seem to forward SIGTERM/SIGINT to the subprocess Avoid DeprecationWarning due to import imp
2 participants