Skip to content

Commit 905bd8e

Browse files
committed
subprocess: Do extra work for error processing only for preexec_fn
1 parent b5b3b12 commit 905bd8e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

uvloop/handles/process.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ cdef class UVProcess(UVHandle):
9090

9191
os_close(self._errpipe_write)
9292

93-
errpipe_data = bytearray()
94-
while True:
95-
part = os_read(self._errpipe_read, 50000)
96-
errpipe_data += part
97-
if not part or len(errpipe_data) > 50000:
98-
break
93+
if preexec_fn is not None:
94+
errpipe_data = bytearray()
95+
while True:
96+
part = os_read(self._errpipe_read, 50000)
97+
errpipe_data += part
98+
if not part or len(errpipe_data) > 50000:
99+
break
99100

100101
finally:
101102
os_close(self._errpipe_read)
@@ -121,7 +122,7 @@ cdef class UVProcess(UVHandle):
121122
if debug_flags & __PROCESS_DEBUG_SLEEP_AFTER_FORK:
122123
time_sleep(1)
123124

124-
if errpipe_data:
125+
if preexec_fn is not None and errpipe_data:
125126
# preexec_fn has raised an exception. The child
126127
# process must be dead now.
127128
try:

0 commit comments

Comments
 (0)