Skip to content

Commit 5c612c4

Browse files
author
Andy Babic
committed
Make Local instances clearable (without deleting)
1 parent 30d891f commit 5c612c4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

asgiref/local.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _get_storage(self):
8484
self._context_refs.add(context_obj)
8585
return getattr(context_obj, self._attr_name)
8686

87-
def __del__(self):
87+
def clear(self):
8888
try:
8989
for context_obj in self._context_refs:
9090
try:
@@ -96,6 +96,9 @@ def __del__(self):
9696
# to _IterationGuard being None.
9797
pass
9898

99+
def __del__(self):
100+
self.clear()
101+
99102
def __getattr__(self, key):
100103
with self._thread_lock:
101104
storage = self._get_storage()

0 commit comments

Comments
 (0)