Skip to content

Commit

Permalink
fix: dont raise errors when shutting down transport
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Aug 27, 2018
1 parent 0391b50 commit 792df62
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sentry_sdk/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@ def spawn_thread(transport):

def thread():
disabled_until = None

# copy to local var in case transport._queue is set to None
queue = transport._queue

while 1:
item = transport._queue.get()
item = queue.get()
if item is _SHUTDOWN:
transport._queue.task_done()
queue.task_done()
break

if disabled_until is not None:
if datetime.utcnow() < disabled_until:
transport._queue.task_done()
queue.task_done()
continue
disabled_until = None

Expand All @@ -92,7 +96,7 @@ def thread():
print("Could not send sentry event", file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
finally:
transport._queue.task_done()
queue.task_done()

t = threading.Thread(target=thread)
t.setDaemon(True)
Expand Down

0 comments on commit 792df62

Please sign in to comment.