summaryrefslogtreecommitdiff
path: root/lib/extras.py
diff options
context:
space:
mode:
authorOleksandr Shulgin <oleksandr.shulgin@zalando.de>2015-10-15 12:27:43 +0200
committerOleksandr Shulgin <oleksandr.shulgin@zalando.de>2015-10-15 12:27:43 +0200
commit8e518d4954ba5bf33e44c1eedd5fd6633ea3b747 (patch)
treef86817a253e388abf6c25b3c7199e443f27356b8 /lib/extras.py
parent9ab38ee8c5faf1241adaec0467ff6d83d1af6434 (diff)
parent6763578cc0371fcada1ecc6f6bf7be70220d515b (diff)
downloadpsycopg2-8e518d4954ba5bf33e44c1eedd5fd6633ea3b747.tar.gz
Merge branch 'master' into feature/replication-protocol
Diffstat (limited to 'lib/extras.py')
-rw-r--r--lib/extras.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/extras.py b/lib/extras.py
index 913a6aa..e0fd8ef 100644
--- a/lib/extras.py
+++ b/lib/extras.py
@@ -735,15 +735,20 @@ def wait_select(conn):
from psycopg2.extensions import POLL_OK, POLL_READ, POLL_WRITE
while 1:
- state = conn.poll()
- if state == POLL_OK:
- break
- elif state == POLL_READ:
- select.select([conn.fileno()], [], [])
- elif state == POLL_WRITE:
- select.select([], [conn.fileno()], [])
- else:
- raise conn.OperationalError("bad state from poll: %s" % state)
+ try:
+ state = conn.poll()
+ if state == POLL_OK:
+ break
+ elif state == POLL_READ:
+ select.select([conn.fileno()], [], [])
+ elif state == POLL_WRITE:
+ select.select([], [conn.fileno()], [])
+ else:
+ raise conn.OperationalError("bad state from poll: %s" % state)
+ except KeyboardInterrupt:
+ conn.cancel()
+ # the loop will be broken by a server error
+ continue
def _solve_conn_curs(conn_or_curs):