#30787: update_connections_time_zone fails with parallel tests
---------------------------------------------+------------------------
Reporter: Justin Walters | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
I have extended the DiscoverRunner to wrap
`override_settings(USE_TZ=False)` around setup_databases and run_suite, in
order to allow my tests and migrations to peacefully use timezone-naive
test data.
I just began using the `manage.py test --parallel` to run my tests in
parallel. However, even though my tests succeed, the test runner crashes
before exiting, with the below exception. My test database does not get
torn down as a result. If I remove the `override_settings(USE_TZ=False)`
the exception never occurs.
My guess is that `django.test.signals.update_connections_time_zone` does
not gracefully handle the connection being closed before the function
completes. But I think it smells to just silence this exception in this
function, and am worried that perhaps my own code somewhere is abusing the
db connection. Thoughts?
{{{
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 371, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-
packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/test.py", line 26, in
run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-
packages/django/core/management/commands/test.py", line 59, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.6/site-packages/django/test/runner.py",
line 603, in run_tests
result = self.run_suite(suite)
File "/code/application/test_runner.py", line 30, in run_suite
return super(TestRunner, self).run_suite(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line
343, in __exit__
self.disable()
File "/usr/local/lib/python3.6/site-packages/django/test/utils.py", line
419, in disable
setting=key, value=new_value, enter=False)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 178, in send
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-
packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
for receiver in self._live_receivers(sender)
File "/usr/local/lib/python3.6/site-packages/django/test/signals.py",
line 74, in update_connections_time_zone
conn.ensure_timezone()
File "/usr/local/lib/python3.6/site-
packages/django/db/backends/postgresql/base.py", line 193, in
ensure_timezone
cursor.execute(self.ops.set_time_zone_sql(), [timezone_name])
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30787>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.305284793cd336b7f31dfcd7c48112a7%40djangoproject.com.