Skip to content

Commit

Permalink
Fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
Pliner committed Mar 22, 2021
1 parent 7bb9434 commit 6b2db0c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions aiopg/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings

import async_timeout
from psycopg2.extensions import TRANSACTION_STATUS_IDLE
import psycopg2.extensions

from .connection import TIMEOUT, connect
from .utils import (
Expand Down Expand Up @@ -237,22 +237,22 @@ def release(self, conn):
return future
assert conn in self._used, (conn, self._used)
self._used.remove(conn)
if not conn.closed:
transaction_status = conn.raw.get_transaction_status()
if transaction_status != TRANSACTION_STATUS_IDLE:
warnings.warn(
f"Invalid transaction status on "
f"released connection: {transaction_status}",
ResourceWarning
)
conn.close()
return future
if self._closing:
conn.close()
else:
self._free.append(conn)
future = asyncio.ensure_future(self._wakeup(), loop=self._loop)
return future
if conn.closed:
return future
transaction_status = conn.raw.get_transaction_status()
if transaction_status != psycopg2.extensions.TRANSACTION_STATUS_IDLE:
warnings.warn(
f"Invalid transaction status on "
f"released connection: {transaction_status}",
ResourceWarning
)
conn.close()
return future
if self._closing:
conn.close()
else:
self._free.append(conn)
return asyncio.ensure_future(self._wakeup(), loop=self._loop)

async def cursor(self, name=None, cursor_factory=None,
scrollable=None, withhold=False, *, timeout=None):
Expand Down

0 comments on commit 6b2db0c

Please sign in to comment.