File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff 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+ * Rare exception when "sys.exit(0)" after query timeouts (PYTHON-752)
1415
15163.11.0
1617======
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ def __init__(self):
6363 self ._started = False
6464 self ._shutdown = False
6565 self ._lock = Lock ()
66+ self ._lock_thread = Lock ()
6667
6768 self ._thread = None
6869
@@ -94,9 +95,11 @@ def maybe_start(self):
9495 should_start = True
9596
9697 if should_start :
97- self ._thread = Thread (target = self ._run_loop , name = "event_loop" )
98- self ._thread .daemon = True
99- self ._thread .start ()
98+ with self ._lock_thread :
99+ if not self ._shutdown :
100+ self ._thread = Thread (target = self ._run_loop , name = "event_loop" )
101+ self ._thread .daemon = True
102+ self ._thread .start ()
100103
101104 self ._notifier .send ()
102105
@@ -126,8 +129,11 @@ def _cleanup(self):
126129 watcher .stop ()
127130
128131 self .notify () # wake the timer watcher
129- log .debug ("Waiting for event loop thread to join..." )
130- self ._thread .join (timeout = 1.0 )
132+
133+ # PYTHON-752 Thread might have just been created and not started
134+ with self ._lock_thread :
135+ self ._thread .join (timeout = 1.0 )
136+
131137 if self ._thread .is_alive ():
132138 log .warning (
133139 "Event loop thread could not be joined, so shutdown may not be clean. "
You can’t perform that action at this time.
0 commit comments