Merge pull request #7572 from wizrds/fix/ws-client-timestamp

Test WebSocket client fix
This commit is contained in:
Matthias 2022-10-11 08:49:47 +02:00 committed by GitHub
commit 8f2a887a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,7 @@ def readable_timedelta(delta):
""" """
attrs = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'microseconds'] attrs = ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'microseconds']
return ", ".join([ return ", ".join([
'%d %s' % (getattr(delta, attr), attr if getattr(delta, attr) > 1 else attr[:-1]) '%d %s' % (getattr(delta, attr), attr if getattr(delta, attr) > 0 else attr[:-1])
for attr in attrs if getattr(delta, attr) for attr in attrs if getattr(delta, attr)
]) ])
@ -170,7 +170,7 @@ class ClientProtocol:
def _calculate_time_difference(self): def _calculate_time_difference(self):
old_last_received_at = self._LAST_RECEIVED_AT old_last_received_at = self._LAST_RECEIVED_AT
self._LAST_RECEIVED_AT = time.time() * 1000 self._LAST_RECEIVED_AT = time.time() * 1e6
time_delta = relativedelta(microseconds=(self._LAST_RECEIVED_AT - old_last_received_at)) time_delta = relativedelta(microseconds=(self._LAST_RECEIVED_AT - old_last_received_at))
return readable_timedelta(time_delta) return readable_timedelta(time_delta)
@ -238,7 +238,7 @@ async def create_client(
except ( except (
asyncio.TimeoutError, asyncio.TimeoutError,
websockets.exceptions.ConnectionClosed websockets.exceptions.WebSocketException
): ):
# Try pinging # Try pinging
try: try:
@ -298,7 +298,7 @@ async def _main(args):
producers = emc_config.get('producers', []) producers = emc_config.get('producers', [])
producer = producers[0] producer = producers[0]
wait_timeout = emc_config.get('wait_timeout', 300) wait_timeout = emc_config.get('wait_timeout', 30)
ping_timeout = emc_config.get('ping_timeout', 10) ping_timeout = emc_config.get('ping_timeout', 10)
sleep_time = emc_config.get('sleep_time', 10) sleep_time = emc_config.get('sleep_time', 10)
message_size_limit = (emc_config.get('message_size_limit', 8) << 20) message_size_limit = (emc_config.get('message_size_limit', 8) << 20)
@ -311,7 +311,8 @@ async def _main(args):
sleep_time=sleep_time, sleep_time=sleep_time,
ping_timeout=ping_timeout, ping_timeout=ping_timeout,
wait_timeout=wait_timeout, wait_timeout=wait_timeout,
max_size=message_size_limit max_size=message_size_limit,
ping_interval=None
) )