diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 9ac166f27..2f8d02fa9 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -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 @@ -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) @@ -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: diff --git a/debug_toolbar/panels/staticfiles.py b/debug_toolbar/panels/staticfiles.py index 37afdcfa6..ea7075939 100644 --- a/debug_toolbar/panels/staticfiles.py +++ b/debug_toolbar/panels/staticfiles.py @@ -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( @@ -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): @@ -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): @@ -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( diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index b93acbeed..07432d22c 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -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. "