Exemplo n.º 1
0
    def on_fork(self, pm):

        sys.stdout.flush()
        sys.stderr.flush()

        self.pr, self.pw = _pipe(blocking_read=False)
        _pyabc.atfork_child_add(self.pr)
Exemplo n.º 2
0
    def on_fork(self, pm):

        sys.stderr.flush()
        self.stdin_read, self.stdin_write = _pipe(blocking_write=False)
        _pyabc.atfork_child_add(self.stdin_write)

        sys.stdout.flush()
        self.stdout_read, self.stdout_write = _pipe(blocking_read=False)
        _pyabc.atfork_child_add(self.stdout_read)
Exemplo n.º 3
0
    def on_parent(self, pid):

        self.f = None

        os.close(self.pw)
        self.pid = pid
        self.pw = None

        self.loop.register(self, self.pr)
        _pyabc.atfork_child_add(self.pr)
Exemplo n.º 4
0
    def on_child(self):

        _pyabc.atfork_child_add(self.pw)
        try:
            res = self.f()
            with os.fdopen(self.pw, "w") as fout:
                pickle.dump(res, fout)
        except:
            traceback.print_exc(file=sys.stderr)
            raise
        return 0
Exemplo n.º 5
0
    def __init__(self, loop):

        super(signal_event_handler, self).__init__(loop)

        self.sig_fd_read, self.sig_fd_write = _pipe(blocking_read=False)

        _pyabc.atfork_child_add(self.sig_fd_read)
        _pyabc.atfork_child_add(self.sig_fd_write)

        self._install_signal_handler(self.sig_fd_write)
        self.registered = False
Exemplo n.º 6
0
    def on_parent(self, pid):

        os.close(self.stdout_write)
        self.stdout_write = None

        os.close(self.stdin_read)
        self.stdin_read = None
        self.stdin_buf = collections.deque()
        self.should_close_stdin = False

        self.pid = pid
        self.path = None
        self.args = None

        # self.loop.register(self, self.stdin_write)
        _pyabc.atfork_child_add(self.stdin_write)

        self.loop.register(self, self.stdout_read)
        _pyabc.atfork_child_add(self.stdout_read)

        self.on_start()