File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -91,27 +91,33 @@ cdef class UVProcess(UVHandle):
9191 self ._restore_signals = restore_signals
9292
9393 loop.active_process_handler = self
94- __forking = 1
95- __forking_loop = loop
94+
9695
9796 if not system.PLATFORM_IS_WINDOWS:
97+ __forking = 1
98+ __forking_loop = loop
9899 system.setForkHandler(< system.OnForkHandler> & __get_fork_handler)
99100
100101 PyOS_BeforeFork()
102+ else :
103+ py_gil_state = PyGILState_Ensure()
101104
102105 err = uv.uv_spawn(loop.uvloop,
103106 < uv.uv_process_t* > self ._handle,
104107 & self .options)
105108
106- __forking = 0
107- __forking_loop = None
109+
108110 if not system.PLATFORM_IS_WINDOWS:
109-
111+ __forking = 0
112+ __forking_loop = None
110113 system.resetForkHandler()
111114
112115 PyOS_AfterFork_Parent()
116+ else :
117+ PyGILState_Release(py_gil_state)
113118
114-
119+ loop.active_process_handler = None
120+
115121
116122 if err < 0 :
117123 self ._close_process_handle()
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ from libc.stdint cimport uint64_t
2828from libc.string cimport memset, strerror, memcpy
2929from libc cimport errno
3030
31+ # Winloop Comment: We need some cleaver hacky techniques for
32+ # preventing slow spawnning processes for MSVC
33+ from cpython.pystate cimport (PyGILState_Ensure, PyGILState_Release,
34+ PyGILState_STATE)
3135from cpython cimport PyObject
3236from cpython cimport PyErr_CheckSignals, PyErr_Occurred
3337from cpython cimport PyThread_get_thread_ident
You can’t perform that action at this time.
0 commit comments