1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Removed threading fallback imports.

Django imports threading in many other places without fallback.
This commit is contained in:
Tim Graham 2015-01-28 09:55:52 -05:00
parent cd91486213
commit 18f3e79b13
6 changed files with 6 additions and 33 deletions

View File

@ -10,10 +10,7 @@ from django.db.backends import utils
from django.db.transaction import TransactionManagementError from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseError, DatabaseErrorWrapper from django.db.utils import DatabaseError, DatabaseErrorWrapper
from django.utils.functional import cached_property from django.utils.functional import cached_property
try: from django.utils.six.moves import _thread as thread
from django.utils.six.moves import _thread as thread
except ImportError:
from django.utils.six.moves import _dummy_thread as thread
NO_DB_ALIAS = '__no_db__' NO_DB_ALIAS = '__no_db__'

View File

@ -39,10 +39,7 @@ import traceback
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
from django.core.signals import request_finished from django.core.signals import request_finished
try: from django.utils.six.moves import _thread as thread
from django.utils.six.moves import _thread as thread
except ImportError:
from django.utils.six.moves import _dummy_thread as thread
# This import does nothing, but it's necessary to avoid some race conditions # This import does nothing, but it's necessary to avoid some race conditions
# in the threading module. See http://code.djangoproject.com/ticket/2330 . # in the threading module. See http://code.djangoproject.com/ticket/2330 .

View File

@ -7,10 +7,7 @@ Synchronization primitives:
""" """
import contextlib import contextlib
try: import threading
import threading
except ImportError:
import dummy_threading as threading
class RWLock(object): class RWLock(object):

View File

@ -6,16 +6,12 @@ import os
import shutil import shutil
import sys import sys
import tempfile import tempfile
import threading
import time import time
import unittest import unittest
import warnings import warnings
from datetime import datetime, timedelta from datetime import datetime, timedelta
try:
import threading
except ImportError:
import dummy_threading as threading
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import SuspiciousOperation, SuspiciousFileOperation from django.core.exceptions import SuspiciousOperation, SuspiciousFileOperation
from django.core.files.base import File, ContentFile from django.core.files.base import File, ContentFile

View File

@ -1,7 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import threading
import time import time
import unittest
from django.conf import settings from django.conf import settings
from django.db import transaction, connection, router from django.db import transaction, connection, router
@ -15,14 +15,6 @@ from multiple_database.routers import TestRouter
from .models import Person from .models import Person
# Some tests require threading, which might not be available. So create a
# skip-test decorator for those test functions.
try:
import threading
except ImportError:
threading = None
requires_threading = unittest.skipUnless(threading, 'requires threading')
# We need to set settings.DEBUG to True so we can capture the output SQL # We need to set settings.DEBUG to True so we can capture the output SQL
# to examine. # to examine.
@ -92,7 +84,6 @@ class SelectForUpdateTests(TransactionTestCase):
list(Person.objects.all().select_for_update(nowait=True)) list(Person.objects.all().select_for_update(nowait=True))
self.assertTrue(self.has_for_update_sql(connection, nowait=True)) self.assertTrue(self.has_for_update_sql(connection, nowait=True))
@requires_threading
@skipUnlessDBFeature('has_select_for_update_nowait') @skipUnlessDBFeature('has_select_for_update_nowait')
def test_nowait_raises_error_on_block(self): def test_nowait_raises_error_on_block(self):
""" """
@ -173,7 +164,6 @@ class SelectForUpdateTests(TransactionTestCase):
# database connection. Close it without waiting for the GC. # database connection. Close it without waiting for the GC.
connection.close() connection.close()
@requires_threading
@skipUnlessDBFeature('has_select_for_update') @skipUnlessDBFeature('has_select_for_update')
@skipUnlessDBFeature('supports_transactions') @skipUnlessDBFeature('supports_transactions')
def test_block(self): def test_block(self):
@ -223,7 +213,6 @@ class SelectForUpdateTests(TransactionTestCase):
p = Person.objects.get(pk=self.person.pk) p = Person.objects.get(pk=self.person.pk)
self.assertEqual('Fred', p.name) self.assertEqual('Fred', p.name)
@requires_threading
@skipUnlessDBFeature('has_select_for_update') @skipUnlessDBFeature('has_select_for_update')
def test_raw_lock_not_available(self): def test_raw_lock_not_available(self):
""" """

View File

@ -1,10 +1,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import sys import sys
try: import threading
import threading
except ImportError:
threading = None
import time import time
from unittest import skipIf, skipUnless from unittest import skipIf, skipUnless