| 392 | return commit_role or commit_tz |
| 393 | |
| 394 | def _close(self): |
| 395 | if self.connection is not None: |
| 396 | # `wrap_database_errors` only works for `putconn` as long as there |
| 397 | # is no `reset` function set in the pool because it is deferred |
| 398 | # into a thread and not directly executed. |
| 399 | with self.wrap_database_errors: |
| 400 | if self.pool: |
| 401 | # Ensure the correct pool is returned. This is a workaround |
| 402 | # for tests so a pool can be changed on setting changes |
| 403 | # (e.g. USE_TZ, TIME_ZONE). |
| 404 | self.connection._pool.putconn(self.connection) |
| 405 | # Connection can no longer be used. |
| 406 | self.connection = None |
| 407 | else: |
| 408 | return self.connection.close() |
| 409 | |
| 410 | def init_connection_state(self): |
| 411 | super().init_connection_state() |