Skip to content

Commit

Permalink
mypy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kristjanvalur committed Apr 10, 2023
1 parent fc93686 commit 20c1429
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ async def shutdown(self) -> None:
def start_timeout(self) -> None:
# handle_request should call this once it has sent the
# websocket.accept() response to start the timeout.
timeout_handler = self.handle_connection_init_timeout()
self.connection_init_timeout_task = asyncio.create_task(timeout_handler)
assert not self.connection_init_timeout_task
self.connection_init_timeout_task = asyncio.create_task(
self.handle_connection_init_timeout()
)

async def handle_connection_init_timeout(self) -> None:
try:
Expand Down Expand Up @@ -157,7 +159,8 @@ async def handle_message(self, message: dict) -> None:
async def handle_connection_init(self, message: ConnectionInitMessage) -> None:
if self.connection_timed_out:
return
self.connection_init_timeout_task.cancel()
if self.connection_init_timeout_task:
self.connection_init_timeout_task.cancel()

if message.payload is not UNSET and not isinstance(message.payload, dict):
await self.close(code=4400, reason="Invalid connection init payload")
Expand Down

0 comments on commit 20c1429

Please sign in to comment.