diff --git a/mitogen/core.py b/mitogen/core.py index 1c1d2e27..19a305a3 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -29,7 +29,7 @@ FORWARD_LOG = 102 ADD_ROUTE = 103 ALLOCATE_ID = 104 -CHUNK_SIZE = 4096 # TODO: this was 16384, but that triggers an unfixed hang. +CHUNK_SIZE = 16384 if __name__ == 'mitogen.core': @@ -125,6 +125,11 @@ def set_cloexec(fd): fcntl.fcntl(fd, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC) +def set_nonblock(fd): + flags = fcntl.fcntl(fd, fcntl.F_GETFL) + fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) + + def io_op(func, *args): try: return func(*args), False @@ -461,6 +466,8 @@ class Side(object): #: active reader set to defer shutdown until the side is disconnected. self.keep_alive = keep_alive + set_nonblock(fd) + def __repr__(self): return '' % (self.stream, self.fd)