File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ def _loop_will_run(self, prepare):
225225
226226
227227_global_loop = None
228- atexit .register (partial ( _cleanup , _global_loop ))
228+ atexit .register (lambda : _cleanup ( _global_loop ))
229229
230230
231231class LibevConnection (Connection ):
Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ IO_dealloc(libevwrapper_IO *self) {
114114};
115115
116116static void io_callback (struct ev_loop * loop , ev_io * watcher , int revents ) {
117+ if (!Py_IsInitialized ()) {
118+ return ;
119+ }
120+
117121 libevwrapper_IO * self = watcher -> data ;
118122 PyObject * result ;
119123 PyGILState_STATE gstate = PyGILState_Ensure ();
@@ -348,6 +352,10 @@ Prepare_dealloc(libevwrapper_Prepare *self) {
348352}
349353
350354static void prepare_callback (struct ev_loop * loop , ev_prepare * watcher , int revents ) {
355+ if (!Py_IsInitialized ()) {
356+ return ;
357+ }
358+
351359 libevwrapper_Prepare * self = watcher -> data ;
352360 PyObject * result = NULL ;
353361 PyGILState_STATE gstate ;
@@ -466,6 +474,10 @@ Timer_dealloc(libevwrapper_Timer *self) {
466474}
467475
468476static void timer_callback (struct ev_loop * loop , ev_timer * watcher , int revents ) {
477+ if (!Py_IsInitialized ()) {
478+ return ;
479+ }
480+
469481 libevwrapper_Timer * self = watcher -> data ;
470482
471483 PyObject * result = NULL ;
You can’t perform that action at this time.
0 commit comments