'A connection can be passed from one thread to the other (#17258).'

def test_pass_connection_between_threads(self):

    Person.objects.create(first_name='John', last_name='Doe')
    def do_thread():
        def runner(main_thread_connection):
            from django.db import connections
            connections['default'] = main_thread_connection
            try:
                Person.objects.get(first_name='John', last_name='Doe')
            except Exception as e:
                exceptions.append(e)
        t = threading.Thread(target=runner, args=[connections['default']])
        t.start()
        t.join()
    exceptions = []
    do_thread()
    self.assertIsInstance(exceptions[0], DatabaseError)
    connections['default'].allow_thread_sharing = False
    exceptions = []
    do_thread()
    self.assertIsInstance(exceptions[0], DatabaseError)
    connections['default'].allow_thread_sharing = True
    exceptions = []
    do_thread()
    self.assertEqual(exceptions, [])
