diff options
| author | Michael Manfre <mmanfre@gmail.com> | 2014-01-09 10:05:15 -0500 |
|---|---|---|
| committer | Michael Manfre <mmanfre@gmail.com> | 2014-02-02 12:47:21 -0500 |
| commit | 3ffeb931869cc68a8e0916219702ee282afc6e9d (patch) | |
| tree | f24020307dd5b529989329bfabfc95effcecffe8 /django/db/backends/postgresql_psycopg2/base.py | |
| parent | 0837eacc4e1fa7916e48135e8ba43f54a7a64997 (diff) | |
Ensure cursors are closed when no longer needed.
This commit touchs various parts of the code base and test framework. Any
found usage of opening a cursor for the sake of initializing a connection
has been replaced with 'ensure_connection()'.
Diffstat (limited to 'django/db/backends/postgresql_psycopg2/base.py')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 33f885d50c..e89a4e604a 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -149,8 +149,10 @@ class DatabaseWrapper(BaseDatabaseWrapper): if conn_tz != tz: cursor = self.connection.cursor() - cursor.execute(self.ops.set_time_zone_sql(), [tz]) - cursor.close() + try: + cursor.execute(self.ops.set_time_zone_sql(), [tz]) + finally: + cursor.close() # Commit after setting the time zone (see #17062) if not self.get_autocommit(): self.connection.commit() |
