Skip to content

Commit

Permalink
Fix wait_for() in blocking client to raise internal TimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed May 29, 2024
1 parent ee3c5ce commit b3407c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions edgedb/blocking_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ async def close(self, timeout=None):
await self._protocol.wait_for(
self._protocol.wait_for_disconnect(), timeout
)
except TimeoutError:
self.terminate()
raise errors.QueryTimeoutError()
except Exception:
self.terminate()
raise
Expand Down
12 changes: 4 additions & 8 deletions edgedb/protocol/blocking_proto.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,14 @@ cdef class BlockingIOProtocol(protocol.SansIOProtocolBackwardsCompatible):
async def wait_for_message(self):
cdef float timeout
if self.deadline > 0:
timeout = self.deadline - time.monotonic()
if timeout <= 0:
self.abort()
raise errors.QueryTimeoutError()
while not self.buffer.take_message():
timeout = self.deadline - time.monotonic()
if timeout <= 0:
self.abort()
raise TimeoutError
try:
self.sock.settimeout(timeout)
data = self.sock.recv(RECV_BUF)
timeout = self.deadline - time.monotonic()
if timeout <= 0:
self.abort()
raise TimeoutError
except OSError as e:
self._disconnect()
raise con_utils.wrap_error(e) from e
Expand Down

0 comments on commit b3407c1

Please sign in to comment.