-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0efc84d
commit 1bbc300
Showing
4 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import threading | ||
|
||
import debug_toolbar.utils | ||
|
||
|
||
class ThreadCollector: | ||
def __init__(self): | ||
self.data = threading.local() | ||
self.data.collection = [] | ||
|
||
def collect(self, item): | ||
if hasattr(self.data, "collection"): | ||
self.data.collection.append(item) | ||
|
||
def get_collection(self): | ||
return getattr(self.data, "collection", []) | ||
|
||
def clear_collection(self): | ||
self.data.collection = [] | ||
|
||
|
||
# monkey patch django debug toolbar so that elastic_panel's broken import still works | ||
# see https://github.com/Benoss/django-elasticsearch-debug-toolbar/pull/21 | ||
debug_toolbar.utils.ThreadCollector = ThreadCollector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters