Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
salty-ivy committed Aug 27, 2024
1 parent 2edc684 commit 72000bb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
4 changes: 1 addition & 3 deletions debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import socket
import threading
from contextvars import copy_context
from functools import lru_cache

from asgiref.sync import iscoroutinefunction, markcoroutinefunction, sync_to_async
Expand Down Expand Up @@ -84,9 +83,7 @@ def __call__(self, request):
print(f"thread_id in __call__ main thread: {threading.get_ident()}")
# Decide whether the toolbar is active for this request.
if self.async_mode:
print(f"Context before entering __acall__: {id(copy_context())}")
return self.__acall__(request)
print(f"Context entering __call__: {id(copy_context())}")
# Decide whether the toolbar is active for this request.
if self.async_mode:
return self.__acall__(request)
Expand Down Expand Up @@ -119,6 +116,7 @@ async def __acall__(self, request):
return response

toolbar = DebugToolbar(request, self.get_response)
print("toolbar", toolbar)

# Activate instrumentation ie. monkey-patch.
for panel in toolbar.enabled_panels:
Expand Down
10 changes: 0 additions & 10 deletions debug_toolbar/panels/staticfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ def _setup(self):
class DebugStaticFilesStorage(configured_storage_cls):
def url(self, path):
# used_static_files.get().append(StaticFile(path))]
print(f"Context before sending signal: {id(copy_context())}")
print(f"thread_id in sync_to_async thread: {get_ident()}")

print(StaticFile(path))

with contextlib.suppress(LookupError):
request_id = request_id_store.get()
staticfiles_used_signal.send(
Expand Down Expand Up @@ -117,7 +114,6 @@ def _store_staticfile_info(
self, sender, staticfiles, request_id, context, **kwargs
):
# print("signal called")
print(f"Context in signal: {context}")
# print(f"thread_id in sync_to_async thread: {get_ident()}")

with contextlib.suppress(LookupError):
Expand All @@ -130,13 +126,8 @@ def _store_staticfile_info(
staticfiles_list.append(staticfiles)

def disable_instrumentation(self):
print("diable instrumentation")
# storage.staticfiles_storage = _original_storage
for receiver in staticfiles_used_signal.receivers:
print(receiver)
staticfiles_used_signal.disconnect(self._store_staticfile_info)
with contextlib.suppress(LookupError):
print(used_static_files.get())

@property
def num_used(self):
Expand All @@ -161,7 +152,6 @@ def process_request(self, request):
return response

def generate_stats(self, request, response):
print("context in storing stats: ", id(copy_context()))
file_paths = used_static_files.get().copy()
used_static_files.get().clear()
self.record_stats(
Expand Down
1 change: 1 addition & 0 deletions debug_toolbar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
def render_panel(request):
"""Render the contents of a panel"""
toolbar = DebugToolbar.fetch(request.GET["store_id"])
print("rendering toolbar", toolbar)
if toolbar is None:
content = _(
"Data for this panel isn't available anymore. "
Expand Down

0 comments on commit 72000bb

Please sign in to comment.