Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cassandra/io/libevreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _loop_will_run(self, prepare):


_global_loop = None
atexit.register(partial(_cleanup, _global_loop))
atexit.register(lambda: _cleanup(_global_loop))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If lambdas are not of taste

Suggested change
atexit.register(lambda: _cleanup(_global_loop))
@atexit.register
def _():
global _global_loop
_cleanup(_global_loop)



class LibevConnection(Connection):
Expand Down
12 changes: 12 additions & 0 deletions cassandra/io/libevwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ IO_dealloc(libevwrapper_IO *self) {
};

static void io_callback(struct ev_loop *loop, ev_io *watcher, int revents) {
if (!Py_IsInitialized()) {
return;
}

libevwrapper_IO *self = watcher->data;
PyObject *result;
PyGILState_STATE gstate = PyGILState_Ensure();
Expand Down Expand Up @@ -348,6 +352,10 @@ Prepare_dealloc(libevwrapper_Prepare *self) {
}

static void prepare_callback(struct ev_loop *loop, ev_prepare *watcher, int revents) {
if (!Py_IsInitialized()) {
return;
}

libevwrapper_Prepare *self = watcher->data;
PyObject *result = NULL;
PyGILState_STATE gstate;
Expand Down Expand Up @@ -466,6 +474,10 @@ Timer_dealloc(libevwrapper_Timer *self) {
}

static void timer_callback(struct ev_loop *loop, ev_timer *watcher, int revents) {
if (!Py_IsInitialized()) {
return;
}

libevwrapper_Timer *self = watcher->data;

PyObject *result = NULL;
Expand Down