nickstenning / honcho

Honcho: a python clone of Foreman. For managing Procfile-based applications.
http://pypi.python.org/pypi/honcho
MIT License
1.59k stars 145 forks source link

SIGINT got exception #183

Closed georgexsh closed 2 years ago

georgexsh commented 8 years ago

after honcho start, press Ctrl-C, will yield exception:

...
  File "venv/local/lib/python2.7/site-packages/honcho/command.py", line 220, in command_start
    manager.loop()
  File "venv/local/lib/python2.7/site-packages/honcho/manager.py", line 110, in loop
    msg = self.events.get(timeout=0.1)
  File "/usr/lib/python2.7/multiprocessing/queues.py", line 131, in get
    if timeout < 0 or not self._poll(timeout):
IOError: [Errno 4] Interrupted system call

this error could be simplely ignored IMO:

*** 111,116 ****
--- 111,120 ----
              except Empty:
                  if exit:
                      break
+             except IOError as e:
+                 if e.errno != errno.EINTR:
+                     raise
+                 exit = True
              else:
                  if msg.type == 'line':
                      self._printer.write(msg)

or use an alternative paradigm:

@@ -2,6 +2,7 @@ import datetime
 import multiprocessing
 import signal
 import sys
+import time

 from .colour import get_colours
 from .compat import Empty
@@ -107,10 +108,11 @@ class Manager(object):

         while 1:
             try:
-                msg = self.events.get(timeout=0.1)
+                msg = self.events.get(False)
             except Empty:
                 if exit:
                     break
+                time.sleep(0.1)
             else:
                 if msg.type == 'line':
                     self._printer.write(msg)
nickstenning commented 2 years ago

Thanks for the report. This was a bug in Python itself which got fixed in 2.7.6.