MCPcopy
hub / github.com/django/django / close

Method close

django/db/backends/base/base.py:344–361  ·  view source on GitHub ↗

Close the connection to the database.

(self)

Source from the content-addressed store, hash-verified

342
343 @async_unsafe
344 def close(self):
345 """Close the connection to the database."""
346 self.validate_thread_sharing()
347 self.run_on_commit = []
348
349 # Don't call validate_no_atomic_block() to avoid making it difficult
350 # to get rid of a connection in an invalid state. The next connect()
351 # will reset the transaction state anyway.
352 if self.closed_in_transaction or self.connection is None:
353 return
354 try:
355 self._close()
356 finally:
357 if self.in_atomic_block:
358 self.closed_in_transaction = True
359 self.needs_rollback = True
360 else:
361 self.connection = None
362
363 # ##### Backend-specific savepoint management methods #####
364

Callers 11

temporary_connectionMethod · 0.95
add_fieldMethod · 0.45
remove_fieldMethod · 0.45
_alter_fieldMethod · 0.45
_closeMethod · 0.45
_nodb_cursorMethod · 0.45
create_test_dbMethod · 0.45
destroy_test_dbMethod · 0.45

Calls 2

_closeMethod · 0.95

Tested by

no test coverage detected