Skip to content

Commit cbdeda8

Browse files
authored
Add ping_data parameter to connection class
1 parent a7b4e4c commit cbdeda8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/websockets/asyncio/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ def __init__(
5555
*,
5656
ping_interval: float | None = 20,
5757
ping_timeout: float | None = 20,
58+
ping_data: Data | None = None,
5859
close_timeout: float | None = 10,
5960
max_queue: int | None | tuple[int | None, int | None] = 16,
6061
write_limit: int | tuple[int, int | None] = 2**15,
6162
) -> None:
6263
self.protocol = protocol
6364
self.ping_interval = ping_interval
6465
self.ping_timeout = ping_timeout
66+
self.ping_data = ping_data
6567
self.close_timeout = close_timeout
6668
self.max_queue: tuple[int | None, int | None]
6769
if isinstance(max_queue, int) or max_queue is None:
@@ -825,7 +827,7 @@ async def keepalive(self) -> None:
825827
# connection to be closed before raising ConnectionClosed.
826828
# However, connection_lost() cancels keepalive_task before
827829
# it gets a chance to resume excuting.
828-
pong_waiter = await self.ping()
830+
pong_waiter = await self.ping(self.ping_data)
829831
if self.debug:
830832
self.logger.debug("% sent keepalive ping")
831833

0 commit comments

Comments
 (0)