@@ -1010,7 +1010,7 @@ async def test_keepalive_times_out(self, getrandbits):
1010
1010
self .connection .start_keepalive ()
1011
1011
# 4 ms: keepalive() sends a ping frame.
1012
1012
await asyncio .sleep (4 * MS )
1013
- # Exiting the context manager sleeps for MS .
1013
+ # Exiting the context manager sleeps for 1 ms .
1014
1014
# 4.x ms: a pong frame is dropped.
1015
1015
# 6 ms: no pong frame is received; the connection is closed.
1016
1016
await asyncio .sleep (2 * MS )
@@ -1026,33 +1026,33 @@ async def test_keepalive_ignores_timeout(self, getrandbits):
1026
1026
getrandbits .return_value = 1918987876
1027
1027
self .connection .start_keepalive ()
1028
1028
# 4 ms: keepalive() sends a ping frame.
1029
- await asyncio .sleep (4 * MS )
1030
- # Exiting the context manager sleeps for MS.
1031
1029
# 4.x ms: a pong frame is dropped.
1030
+ await asyncio .sleep (4 * MS )
1031
+ # Exiting the context manager sleeps for 1 ms.
1032
1032
# 6 ms: no pong frame is received; the connection remains open.
1033
1033
await asyncio .sleep (2 * MS )
1034
1034
# 7 ms: check that the connection is still open.
1035
1035
self .assertEqual (self .connection .state , State .OPEN )
1036
1036
1037
1037
async def test_keepalive_terminates_while_sleeping (self ):
1038
1038
"""keepalive task terminates while waiting to send a ping."""
1039
- self .connection .ping_interval = 2 * MS
1039
+ self .connection .ping_interval = 3 * MS
1040
1040
self .connection .start_keepalive ()
1041
1041
await asyncio .sleep (MS )
1042
1042
await self .connection .close ()
1043
1043
self .assertTrue (self .connection .keepalive_task .done ())
1044
1044
1045
1045
async def test_keepalive_terminates_while_waiting_for_pong (self ):
1046
1046
"""keepalive task terminates while waiting to receive a pong."""
1047
- self .connection .ping_interval = 2 * MS
1048
- self .connection .ping_timeout = 2 * MS
1047
+ self .connection .ping_interval = MS
1048
+ self .connection .ping_timeout = 3 * MS
1049
1049
async with self .drop_frames_rcvd ():
1050
1050
self .connection .start_keepalive ()
1051
- # 2 ms: keepalive() sends a ping frame.
1052
- await asyncio . sleep ( 2 * MS )
1053
- # Exiting the context manager sleeps for MS.
1054
- # 2.x ms: a pong frame is dropped .
1055
- # 3 ms: close the connection before ping_timeout elapses.
1051
+ # 1 ms: keepalive() sends a ping frame.
1052
+ # 1.x ms: a pong frame is dropped.
1053
+ await asyncio . sleep ( MS )
1054
+ # Exiting the context manager sleeps for 1 ms .
1055
+ # 2 ms: close the connection before ping_timeout elapses.
1056
1056
await self .connection .close ()
1057
1057
self .assertTrue (self .connection .keepalive_task .done ())
1058
1058
@@ -1062,9 +1062,9 @@ async def test_keepalive_reports_errors(self):
1062
1062
async with self .drop_frames_rcvd ():
1063
1063
self .connection .start_keepalive ()
1064
1064
# 2 ms: keepalive() sends a ping frame.
1065
- await asyncio .sleep (2 * MS )
1066
- # Exiting the context manager sleeps for MS.
1067
1065
# 2.x ms: a pong frame is dropped.
1066
+ await asyncio .sleep (2 * MS )
1067
+ # Exiting the context manager sleeps for 1 ms.
1068
1068
# 3 ms: inject a fault: raise an exception in the pending pong waiter.
1069
1069
pong_waiter = next (iter (self .connection .pong_waiters .values ()))[0 ]
1070
1070
with self .assertLogs ("websockets" , logging .ERROR ) as logs :
0 commit comments