Skip to content

Commit cff021e

Browse files
Merge pull request apache#1069 from datastax/python-1228
PYTHON-1228 Provide log wrapper to asyncore so it doesnt error
2 parents a1f8e10 + 75affb7 commit cff021e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

cassandra/io/asyncorereactor.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,21 @@
3535

3636
from cassandra.connection import Connection, ConnectionShutdown, NONBLOCKING, Timer, TimerManager
3737

38-
log = logging.getLogger(__name__)
38+
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()
3953

4054
_dispatcher_map = {}
4155

0 commit comments

Comments
 (0)