Remove recusive call of _wait_timeout() due to which python server is crashing

pull/3/head
Ashesh Vashi 2016-06-16 17:49:02 +05:30 committed by Akshay Joshi
parent cef0dc7c88
commit fc295f94a3
1 changed files with 22 additions and 5 deletions

View File

@ -798,14 +798,31 @@ Failed to reset the connection to the server due to following error:
if state == psycopg2.extensions.POLL_OK: if state == psycopg2.extensions.POLL_OK:
return self.ASYNC_OK return self.ASYNC_OK
elif state == psycopg2.extensions.POLL_WRITE: elif state == psycopg2.extensions.POLL_WRITE:
if select.select([], [conn.fileno()], [], time) == ([], [], []): # Wait for the given time and then check the return status
# If three empty lists are returned then the time-out is reached.
timeout_status = select.select([], [conn.fileno()], [], time)
if timeout_status == ([], [], []):
return self.ASYNC_WRITE_TIMEOUT return self.ASYNC_WRITE_TIMEOUT
# Call recursively if no timeout
return self._wait_timeout(conn, time) # poll again to check the state if it is still POLL_WRITE
# then return ASYNC_WRITE_TIMEOUT else return ASYNC_OK.
state = conn.poll()
if state == psycopg2.extensions.POLL_WRITE:
return self.ASYNC_WRITE_TIMEOUT
return self.ASYNC_OK
elif state == psycopg2.extensions.POLL_READ: elif state == psycopg2.extensions.POLL_READ:
if select.select([conn.fileno()], [], [], time) == ([], [], []): # Wait for the given time and then check the return status
# If three empty lists are returned then the time-out is reached.
timeout_status = select.select([conn.fileno()], [], [], time)
if timeout_status == ([], [], []):
return self.ASYNC_READ_TIMEOUT return self.ASYNC_READ_TIMEOUT
return self._wait_timeout(conn, time)
# poll again to check the state if it is still POLL_READ
# then return ASYNC_READ_TIMEOUT else return ASYNC_OK.
state = conn.poll()
if state == psycopg2.extensions.POLL_READ:
return self.ASYNC_READ_TIMEOUT
return self.ASYNC_OK
else: else:
raise psycopg2.OperationalError( raise psycopg2.OperationalError(
"poll() returned %s from _wait_timeout function" % state "poll() returned %s from _wait_timeout function" % state