From d851a3c8a6bb2b1e8c8cc4f8d6cba0f4a2abe216 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 17 Oct 2013 09:22:46 +0200 Subject: Update usage of the threading module. --- debug_toolbar/middleware.py | 8 ++++---- tests/tests.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index c361a49..6512de6 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -43,7 +43,7 @@ class DebugToolbarMiddleware(object): @classmethod def get_current(cls): - return cls.debug_toolbars.get(threading.currentThread().ident) + return cls.debug_toolbars.get(threading.current_thread().ident) def __init__(self): self._urlconfs = {} @@ -103,11 +103,11 @@ class DebugToolbarMiddleware(object): toolbar = DebugToolbar(request) for panel in toolbar.panels: panel.process_request(request) - self.__class__.debug_toolbars[threading.currentThread().ident] = toolbar + self.__class__.debug_toolbars[threading.current_thread().ident] = toolbar def process_view(self, request, view_func, view_args, view_kwargs): __traceback_hide__ = True - toolbar = self.__class__.debug_toolbars.get(threading.currentThread().ident) + toolbar = self.__class__.debug_toolbars.get(threading.current_thread().ident) if not toolbar: return result = None @@ -119,7 +119,7 @@ class DebugToolbarMiddleware(object): def process_response(self, request, response): __traceback_hide__ = True - ident = threading.currentThread().ident + ident = threading.current_thread().ident toolbar = self.__class__.debug_toolbars.get(ident) if not toolbar or request.is_ajax() or getattr(response, 'streaming', False): return response diff --git a/tests/tests.py b/tests/tests.py index 67b67bf..32f8d6b 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1,5 +1,7 @@ from __future__ import unicode_literals +import threading + import django from django.conf import settings from django.contrib.auth.models import User @@ -8,7 +10,6 @@ from django.http import HttpResponse from django.test import TestCase, RequestFactory from django.template import Template, Context from django.utils import six -from django.utils.six.moves import _thread from django.utils import unittest from debug_toolbar.middleware import DebugToolbarMiddleware @@ -50,7 +51,7 @@ class BaseTestCase(TestCase): response = HttpResponse() toolbar = DebugToolbar(request) - DebugToolbarMiddleware.debug_toolbars[_thread.get_ident()] = toolbar + DebugToolbarMiddleware.debug_toolbars[threading.current_thread().ident] = toolbar self.request = request self.response = response -- cgit v1.2.3