Skip to content

Commit

Permalink
partial fix for issue circus-tent#979
Browse files Browse the repository at this point in the history
avoir the main and blocking exception about "I/O operation on closed file"
with minimal changes and risks
  • Loading branch information
thefab committed May 11, 2016
1 parent 67e793f commit 234e86c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions circus/stream/redirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def __init__(self, stdout_redirect, stderr_redirect, buffer=1024,
self.buffer = buffer
self.loop = loop or ioloop.IOLoop.instance()

def _start_one(self, stream_name, process, pipe):
fd = pipe.fileno()
def _start_one(self, fd, stream_name, process, pipe):
if fd not in self._active:
handler = self.Handler(self, stream_name, process, pipe)
self.loop.add_handler(fd, handler, ioloop.IOLoop.READ)
Expand All @@ -55,8 +54,9 @@ def _start_one(self, stream_name, process, pipe):

def start(self):
count = 0
for name, process, pipe in self.pipes.values():
count += self._start_one(name, process, pipe)
for fd, value in self.pipes.items():
name, process, pipe = value
count += self._start_one(fd, name, process, pipe)
self.running = True
return count

Expand Down Expand Up @@ -87,7 +87,7 @@ def add_redirections(self, process):
self._stop_one(fd)
self.pipes[fd] = name, process, pipe
if self.running:
self._start_one(name, process, pipe)
self._start_one(fd, name, process, pipe)
process.redirected = True

def remove_fd(self, fd):
Expand Down

0 comments on commit 234e86c

Please sign in to comment.