service: don't sleep on empty Select during shutdown.

Avoids a select error during random CTRL+C.
pull/244/head
David Wilson 7 years ago
parent ad1f624750
commit 42cc009b60

@ -330,7 +330,10 @@ class Pool(object):
thread.start() thread.start()
self._threads.append(thread) self._threads.append(thread)
closed = False
def stop(self): def stop(self):
self.closed = True
self._select.close() self._select.close()
for th in self._threads: for th in self._threads:
th.join() th.join()
@ -338,7 +341,7 @@ class Pool(object):
service.on_shutdown() service.on_shutdown()
def _worker_run(self): def _worker_run(self):
while True: while not self.closed:
try: try:
msg = self._select.get() msg = self._select.get()
except (mitogen.core.ChannelError, mitogen.core.LatchError): except (mitogen.core.ChannelError, mitogen.core.LatchError):

Loading…
Cancel
Save