@@ -79,10 +79,16 @@ cdef class UVProcess(UVHandle):
79
79
80
80
if _PyImport_ReleaseLock() < 0 :
81
81
# See CPython/posixmodule.c for details
82
- self ._abort_init()
82
+ if err < 0 :
83
+ self ._abort_init()
84
+ else :
85
+ self ._close()
83
86
raise RuntimeError (' not holding the import lock' )
84
87
85
88
if err < 0 :
89
+ if UVLOOP_DEBUG and uv.uv_is_active(self ._handle):
90
+ raise RuntimeError (
91
+ ' active uv_process_t handle after failed uv_spawn' )
86
92
self ._abort_init()
87
93
raise convert_error(err)
88
94
@@ -109,6 +115,14 @@ cdef class UVProcess(UVHandle):
109
115
# Might be already closed
110
116
pass
111
117
118
+ fds_to_close = self ._fds_to_close
119
+ self ._fds_to_close = None
120
+ for fd in fds_to_close:
121
+ os_close(fd)
122
+
123
+ for fd in restore_inheritable:
124
+ os_set_inheritable(fd, False )
125
+
112
126
# asyncio caches the PID in BaseSubprocessTransport,
113
127
# so that the transport knows what the PID was even
114
128
# after the process is finished.
@@ -122,14 +136,6 @@ cdef class UVProcess(UVHandle):
122
136
# untrack this handle.
123
137
self ._loop._track_process(self )
124
138
125
- for fd in restore_inheritable:
126
- os_set_inheritable(fd, False )
127
-
128
- fds_to_close = self ._fds_to_close
129
- self ._fds_to_close = None
130
- for fd in fds_to_close:
131
- os_close(fd)
132
-
133
139
if debug_flags & __PROCESS_DEBUG_SLEEP_AFTER_FORK:
134
140
time_sleep(1 )
135
141
@@ -216,7 +222,7 @@ cdef class UVProcess(UVHandle):
216
222
217
223
for i in range (arr_len):
218
224
el = arr[i]
219
- # NB: PyBytes_AsSptring doesn't copy the data;
225
+ # NB: PyBytes_AsString doesn't copy the data;
220
226
# we have to be careful when the "arr" is GCed,
221
227
# and it shouldn't be ever mutated.
222
228
ret[i] = PyBytes_AsString(el)
@@ -503,10 +509,12 @@ cdef class UVProcessTransport(UVProcess):
503
509
504
510
assert len (io) == 3
505
511
for idx in range (3 ):
512
+ iocnt = & self .iocnt[idx]
506
513
if io[idx] is not None :
507
- iocnt = & self .iocnt[idx]
508
514
iocnt.flags = uv.UV_INHERIT_FD
509
515
iocnt.data.fd = io[idx]
516
+ else :
517
+ iocnt.flags = uv.UV_IGNORE
510
518
511
519
cdef _call_connection_made(self , waiter):
512
520
try :
0 commit comments