fix database connection bug

Status Job ID Name Coverage
  Test
failed #37722
regular ubuntu
django-tests

00:02:29

failed #36830
regular ubuntu
django-tests

00:02:29

 
Name Stage Failure
failed
django-tests Test
    six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python3.5/dist-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/base/base.py", line 231, in _cursor
return self._prepare_cursor(self.create_cursor(name))
File "/usr/local/lib/python3.5/dist-packages/django/db/backends/postgresql/base.py", line 220, in create_cursor
cursor = self.connection.cursor()
django.db.utils.InterfaceError: connection already closed
ERROR: Job failed: exit code 1