

def _reload_stream(self, key, val):
    parts = key.split('.', 1)
    stream_type = ('stdout' if (parts[0] == 'stdout_stream') else 'stderr')
    old_stream = (self.stream_redirector.get_stream(stream_type) if self.stream_redirector else None)
    if (stream_type == 'stdout'):
        self.stdout_stream_conf[parts[1]] = val
        new_stream = get_stream(self.stdout_stream_conf, reload=True)
        self.stdout_stream = new_stream
    else:
        self.stderr_stream_conf[parts[1]] = val
        new_stream = get_stream(self.stderr_stream_conf, reload=True)
        self.stderr_stream = new_stream
    if self.stream_redirector:
        self.stream_redirector.change_stream(stream_type, new_stream)
    else:
        self.stream_redirector = self._redirector_class(self.stdout_stream, self.stderr_stream, loop=self.loop)
    if old_stream:
        if hasattr(old_stream, 'close'):
            old_stream.close()
        return 0
    self.stream_redirector.start()
    return 1

dataset/ETHPy150Open circus-tent/circus/circus/watcher.py Watcher._reload_stream/original