changeset 120:57375deb17c3

fixed an issue where sending the parent a USR1 when a child is in an infinite loop crashes the parent.
author David Stanek <dstanek@dstanek.com>
date Wed, 21 Oct 2009 14:31:37 -0400
parents 00a660fd9cb4
children 37761d28a1b0
files flup/server/preforkserver.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/flup/server/preforkserver.py	Wed Oct 21 09:29:33 2009 -0700
     1.2 +++ b/flup/server/preforkserver.py	Wed Oct 21 14:31:37 2009 -0400
     1.3 @@ -146,7 +146,9 @@
     1.4                  # children that need to die.
     1.5                  timeout = 2
     1.6  
     1.7 -            w = (time.time() > self._last_purge + 10) and self._children_to_purge or []
     1.8 +            w = []
     1.9 +            if (time.time() > self._last_purge + 10):
    1.10 +                w = [x for x in self._children_to_purge if x.fileno() != -1]
    1.11              try:
    1.12                  r, w, e = select.select(r, w, [], timeout)
    1.13              except select.error, e:
    1.14 @@ -287,6 +289,7 @@
    1.15              if self._children.has_key(pid): # Sanity check.
    1.16                  if self._children[pid]['file'] is not None:
    1.17                      self._children[pid]['file'].close()
    1.18 +                    self._children[pid]['file'] = None
    1.19                  del self._children[pid]
    1.20  
    1.21      def _spawnChild(self, sock):