Commit 18f3e79b authored by Tim Graham's avatar Tim Graham
Browse files

Removed threading fallback imports.

Django imports threading in many other places without fallback.
parent cd914862
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -10,10 +10,7 @@ from django.db.backends import utils
from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseError, DatabaseErrorWrapper
from django.utils.functional import cached_property
try:
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__'
+1 −4
Original line number Diff line number Diff line
@@ -39,10 +39,7 @@ import traceback
from django.apps import apps
from django.conf import settings
from django.core.signals import request_finished
try:
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
# in the threading module. See http://code.djangoproject.com/ticket/2330 .
+1 −4
Original line number Diff line number Diff line
@@ -7,10 +7,7 @@ Synchronization primitives:
"""

import contextlib
try:
import threading
except ImportError:
    import dummy_threading as threading


class RWLock(object):
+1 −5
Original line number Diff line number Diff line
@@ -6,16 +6,12 @@ import os
import shutil
import sys
import tempfile
import threading
import time
import unittest
import warnings
from datetime import datetime, timedelta

try:
    import threading
except ImportError:
    import dummy_threading as threading

from django.core.cache import cache
from django.core.exceptions import SuspiciousOperation, SuspiciousFileOperation
from django.core.files.base import File, ContentFile
+1 −12
Original line number Diff line number Diff line
from __future__ import unicode_literals

import threading
import time
import unittest

from django.conf import settings
from django.db import transaction, connection, router
@@ -15,14 +15,6 @@ from multiple_database.routers import TestRouter

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
# to examine.
@@ -92,7 +84,6 @@ class SelectForUpdateTests(TransactionTestCase):
            list(Person.objects.all().select_for_update(nowait=True))
        self.assertTrue(self.has_for_update_sql(connection, nowait=True))

    @requires_threading
    @skipUnlessDBFeature('has_select_for_update_nowait')
    def test_nowait_raises_error_on_block(self):
        """
@@ -173,7 +164,6 @@ class SelectForUpdateTests(TransactionTestCase):
            # database connection. Close it without waiting for the GC.
            connection.close()

    @requires_threading
    @skipUnlessDBFeature('has_select_for_update')
    @skipUnlessDBFeature('supports_transactions')
    def test_block(self):
@@ -223,7 +213,6 @@ class SelectForUpdateTests(TransactionTestCase):
        p = Person.objects.get(pk=self.person.pk)
        self.assertEqual('Fred', p.name)

    @requires_threading
    @skipUnlessDBFeature('has_select_for_update')
    def test_raw_lock_not_available(self):
        """
Loading