diff options
| author | Jannis Leidel | 2013-05-27 08:09:28 -0700 | 
|---|---|---|
| committer | Jannis Leidel | 2013-05-27 08:09:28 -0700 | 
| commit | 25ea0b4b33ae77ccaf12de5fdb467c9270d948ef (patch) | |
| tree | 47680fd6e21f00812f821345f747d56bf6d3e306 /debug_toolbar | |
| parent | 5ae6fcc61c7596b4980e85186f3737fad01a0ad4 (diff) | |
| parent | 1a7609c82994df4c78978073cfa6a5b04335b8ed (diff) | |
| download | django-debug-toolbar-25ea0b4b33ae77ccaf12de5fdb467c9270d948ef.tar.bz2 | |
Merge pull request #333 from calvinchengx/master
Use threading instead of thread. Resolve _DummyThread bug.
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/middleware.py | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index 2c36a19..1ad1942 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -2,7 +2,7 @@  Debug Toolbar middleware  """  import imp -import thread +import threading  from django.conf import settings  from django.http import HttpResponseRedirect @@ -14,6 +14,7 @@ import debug_toolbar.urls  from debug_toolbar.toolbar.loader import DebugToolbar  _HTML_TYPES = ('text/html', 'application/xhtml+xml') +threading._DummyThread._Thread__stop = lambda x: 1  # Handles python threading module bug - http://bugs.python.org/issue14308  def replace_insensitive(string, target, replacement): @@ -38,7 +39,7 @@ class DebugToolbarMiddleware(object):      @classmethod      def get_current(cls): -        return cls.debug_toolbars.get(thread.get_ident()) +        return cls.debug_toolbars.get(threading.currentThread().ident)      def __init__(self):          self._urlconfs = {} @@ -98,11 +99,11 @@ class DebugToolbarMiddleware(object):              toolbar = DebugToolbar(request)              for panel in toolbar.panels:                  panel.process_request(request) -            self.__class__.debug_toolbars[thread.get_ident()] = toolbar +            self.__class__.debug_toolbars[threading.currentThread().ident] = toolbar      def process_view(self, request, view_func, view_args, view_kwargs):          __traceback_hide__ = True -        toolbar = self.__class__.debug_toolbars.get(thread.get_ident()) +        toolbar = self.__class__.debug_toolbars.get(threading.currentThread().ident)          if not toolbar:              return          result = None @@ -114,7 +115,7 @@ class DebugToolbarMiddleware(object):      def process_response(self, request, response):          __traceback_hide__ = True -        ident = thread.get_ident() +        ident = threading.currentThread().ident          toolbar = self.__class__.debug_toolbars.get(ident)          if not toolbar or request.is_ajax():              return response | 
