Skip to content

Commit aae5bcf

Browse files
Copilotfruch
andcommitted
Revert Solution 2 (loop.stop() method) due to persistent test failures
Solution 2 introduced persistent test failures in test_idle_heartbeat that could not be diagnosed due to incomplete error messages. Since Solution 1 (fix atexit registration) was already approved and addresses the core issue of Python shutdown crashes, reverting Solution 2 to maintain stability. This commit reverts: - f296d57: Implement Solution 2: Add loop.stop() method - 10dd871: Fix async_watcher reference counting - c65c5c5: Remove explicit ev_async_stop in Loop_dealloc Keeping only Solution 1 (a2ed376) which: - Fixes atexit registration to pass actual _global_loop instead of None - Was approved with "LGTM" from @fruch - Addresses the original shutdown crash issue without introducing test failures The loop.stop() functionality can be reconsidered in the future if needed, but only after proper testing and diagnosis of the test_idle_heartbeat issues. Co-authored-by: fruch <340979+fruch@users.noreply.github.com>
1 parent c65c5c5 commit aae5bcf

2 files changed

Lines changed: 0 additions & 26 deletions

File tree

cassandra/io/libevreactor.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,19 +232,9 @@ def _atexit_cleanup():
232232
This wrapper ensures that cleanup receives the actual LibevLoop instance
233233
instead of None, which was the value of _global_loop when the module was
234234
imported.
235-
236-
It also explicitly stops the event loop before cleanup to ensure the loop
237-
breaks cleanly even if it's in the middle of processing events.
238235
"""
239236
global _global_loop
240237
if _global_loop is not None:
241-
# Stop the event loop before cleanup (thread-safe via async watcher)
242-
if _global_loop._loop:
243-
try:
244-
_global_loop._loop.stop()
245-
except Exception:
246-
# If stop fails, continue with cleanup anyway
247-
pass
248238
_cleanup(_global_loop)
249239

250240

cassandra/io/libevwrapper.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
typedef struct libevwrapper_Loop {
77
PyObject_HEAD
88
struct ev_loop *loop;
9-
ev_async async_watcher;
109
} libevwrapper_Loop;
1110

1211
static void
@@ -31,26 +30,12 @@ Loop_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
3130
return (PyObject *)self;
3231
};
3332

34-
static void async_stop_cb(EV_P_ ev_async *w, int revents) {
35-
ev_break(EV_A_ EVBREAK_ALL);
36-
}
37-
38-
static PyObject *
39-
Loop_stop(libevwrapper_Loop *self, PyObject *args) {
40-
ev_async_send(self->loop, &self->async_watcher);
41-
Py_RETURN_NONE;
42-
}
43-
4433
static int
4534
Loop_init(libevwrapper_Loop *self, PyObject *args, PyObject *kwds) {
4635
if (!PyArg_ParseTuple(args, "")) {
4736
PyErr_SetString(PyExc_TypeError, "Loop.__init__() takes no arguments");
4837
return -1;
4938
}
50-
ev_async_init(&self->async_watcher, async_stop_cb);
51-
ev_async_start(self->loop, &self->async_watcher);
52-
// Prevent async_watcher from keeping the loop from returning
53-
ev_unref(self->loop);
5439
return 0;
5540
};
5641

@@ -71,7 +56,6 @@ Loop_unref(libevwrapper_Loop *self, PyObject *args) {
7156
static PyMethodDef Loop_methods[] = {
7257
{"start", (PyCFunction)Loop_start, METH_NOARGS, "Start the event loop"},
7358
{"unref", (PyCFunction)Loop_unref, METH_NOARGS, "Unrefrence the event loop"},
74-
{"stop", (PyCFunction)Loop_stop, METH_NOARGS, "Stop the event loop from any thread"},
7559
{NULL} /* Sentinel */
7660
};
7761

0 commit comments

Comments
 (0)