Skip to content

Commit 79947ba

Browse files
authored
Merge pull request scylladb#827 from datastax/python-close-dispatchers
The asyncore event loop shouldn't be awoken once closed, call manuall…
2 parents 496391e + cbb2bad commit 79947ba

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Bug Fixes
1111
* Use of DCAwareRoundRobinPolicy raises NoHostAvailable exception (PYTHON-781)
1212
* Not create two sessions by default in CQLEngine (PYTHON-814)
1313
* Bug when subclassing AyncoreConnection (PYTHON-827)
14+
* Error at cleanup when closing the asyncore connections (PYTHON-829)
1415

1516
3.11.0
1617
======

cassandra/io/asyncorereactor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ def _cleanup(self):
279279
if not self._thread:
280280
return
281281

282+
# The loop shouldn't be woken up from here onwards since it won't be running
283+
self._loop_dispatcher._notified = True
284+
282285
log.debug("Waiting for event loop thread to join...")
283286
self._thread.join(timeout=1.0)
284287
if self._thread.is_alive():
@@ -288,9 +291,12 @@ def _cleanup(self):
288291

289292
log.debug("Event loop thread was joined")
290293

291-
# Ensure all connections are closed and in-flight requests cancelled
294+
# Ensure all connections are closed and in-flight requests cancelled
292295
for conn in tuple(_dispatcher_map.values()):
293296
conn.close()
297+
# The event loop should be closed, so we call remaining asyncore.close
298+
# callbacks from here
299+
self._timers.service_timeouts()
294300

295301
log.debug("Dispatchers were closed")
296302

0 commit comments

Comments
 (0)