Skip to content

Commit

Permalink
Better garbage-collection on exceptions in sync_to_async (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahajahangir committed Apr 30, 2023
1 parent 30d891f commit e22d765
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asgiref/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ def thread_handler(self, loop, source_task, exc_info, func, *args, **kwargs):
else:
self.launch_map[current_thread] = source_task
parent_set = True
source_task = (
None # allow the task to be garbage-collected in case of exceptions
)
# Run the function
try:
# If we have an exception, run the function inside the except block
Expand Down

0 comments on commit e22d765

Please sign in to comment.