Commit e174aad3 authored by Igor Nehoroshev's avatar Igor Nehoroshev Committed by GitHub

Raise ConnectionError in send_request if state is not OPEN (#248)

Co-authored-by: default avatarIgor Nehoroshev <igor.nehoroshev@martem.ee>
parent 7bca18e3
......@@ -137,10 +137,17 @@ class UASocketProtocol(asyncio.Protocol):
Returns response object if no callback is provided.
"""
timeout = self.timeout if timeout is None else timeout
data = await asyncio.wait_for(
self._send_request(request, timeout, message_type),
timeout if timeout else None
)
try:
data = await asyncio.wait_for(
self._send_request(request, timeout, message_type),
timeout if timeout else None
)
except Exception:
if self.state != self.OPEN:
raise ConnectionError("Connection is closed") from None
raise
self.check_answer(data, f" in response to {request.__class__.__name__}")
return data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment