File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 11import os
2+ import time
23import warnings
3- from threading import Thread , Lock , Event
4+ from threading import Thread , Lock
45from contextlib import contextmanager
56
67import sentry_sdk
@@ -161,7 +162,7 @@ def __init__(
161162 self ._thread_lock = Lock ()
162163 self ._aggregate_lock = Lock ()
163164 self ._thread_for_pid = None # type: Optional[int]
164- self .__shutdown_requested = Event ()
165+ self ._running = True
165166
166167 def flush (self ):
167168 # type: (...) -> None
@@ -207,10 +208,10 @@ def _ensure_running(self):
207208
208209 def _thread ():
209210 # type: (...) -> None
210- running = True
211- while running :
212- running = not self .__shutdown_requested . wait ( self . flush_interval )
213- self .flush ()
211+ while self . _running :
212+ time . sleep ( self . flush_interval )
213+ if self ._running :
214+ self .flush ()
214215
215216 thread = Thread (target = _thread )
216217 thread .daemon = True
@@ -219,7 +220,7 @@ def _thread():
219220 except RuntimeError :
220221 # Unfortunately at this point the interpreter is in a state that no
221222 # longer allows us to spawn a thread and we have to bail.
222- self .__shutdown_requested . set ()
223+ self ._running = False
223224 return None
224225
225226 self ._thread = thread
@@ -270,4 +271,4 @@ def add_session(
270271
271272 def kill (self ):
272273 # type: (...) -> None
273- self .__shutdown_requested . set ()
274+ self ._running = False
You can’t perform that action at this time.
0 commit comments