Browse Source

Unregister file descriptors when streams close. Otherwise, Supervisor spins the CPU when a child process closes stdout or stderr.

Shane Hathaway 10 năm trước cách đây
mục cha
commit
5e345e73e9
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      supervisor/supervisord.py

+ 6 - 0
supervisor/supervisord.py

@@ -220,6 +220,9 @@ class Supervisor:
                             'read event caused by %(dispatcher)r',
                             dispatcher=dispatcher)
                         dispatcher.handle_read_event()
+                        if (not dispatcher.readable()
+                                and not dispatcher.writable()):
+                            self.options.poller.unregister(fd)
                     except asyncore.ExitNow:
                         raise
                     except:
@@ -233,6 +236,9 @@ class Supervisor:
                             'write event caused by %(dispatcher)r',
                             dispatcher=dispatcher)
                         dispatcher.handle_write_event()
+                        if (not dispatcher.readable()
+                                and not dispatcher.writable()):
+                            self.options.poller.unregister(fd)
                     except asyncore.ExitNow:
                         raise
                     except: