Skip to content

Commit 2473aae

Browse files
authored
Merge pull request apache#1095 from datastax/python-1266
PYTHON-1266: Fix asyncore race condition cause logging exception on shutdown
2 parents 653ef97 + dc3f2f8 commit 2473aae

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Features
66
--------
77
* Ensure the driver can connect when invalid peer hosts are in system.peers (PYTHON-1260)
88

9+
Bug Fixes
10+
---------
11+
* Asyncore race condition cause logging exception on shutdown (PYTHON-1266)
12+
913
Others
1014
------
1115
* Drop Python 3.4 support (PYTHON-1220)

cassandra/io/asyncorereactor.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,7 @@
3636
from cassandra.connection import Connection, ConnectionShutdown, NONBLOCKING, Timer, TimerManager
3737

3838

39-
# TODO: Remove when Python 2 is removed
40-
class LogWrapper(object):
41-
""" PYTHON-1228. If our logger has disappeared, there's nothing we can do, so just execute nothing """
42-
def __init__(self):
43-
self._log = logging.getLogger(__name__)
44-
45-
def __getattr__(self, name):
46-
try:
47-
return getattr(self._log, name)
48-
except:
49-
return lambda *args, **kwargs: None
50-
51-
52-
log = LogWrapper()
39+
log = logging.getLogger(__name__)
5340

5441
_dispatcher_map = {}
5542

@@ -262,7 +249,13 @@ def _run_loop(self):
262249
self._loop_dispatcher.loop(self.timer_resolution)
263250
self._timers.service_timeouts()
264251
except Exception:
265-
log.debug("Asyncore event loop stopped unexepectedly", exc_info=True)
252+
try:
253+
log.debug("Asyncore event loop stopped unexpectedly", exc_info=True)
254+
except Exception:
255+
# TODO: Remove when Python 2 support is removed
256+
# PYTHON-1266. If our logger has disappeared, there's nothing we
257+
# can do, so just log nothing.
258+
pass
266259
break
267260
self._started = False
268261

0 commit comments

Comments
 (0)