Explorar o código

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

Shane Hathaway %!s(int64=10) %!d(string=hai) anos
pai
achega
7d2cb94291
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      supervisor/supervisord.py

+ 6 - 0
supervisor/supervisord.py

@@ -225,6 +225,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:
@@ -238,6 +241,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: