From dc1fa7bd3fcff84fe77d58ca5b8ef731d176a3bc Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Fri, 17 Apr 2020 22:09:36 +0100 Subject: [PATCH] add reconnect delay jitter Close #227 --- steam/client/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/steam/client/__init__.py b/steam/client/__init__.py index 55e817c..822a6d0 100644 --- a/steam/client/__init__.py +++ b/steam/client/__init__.py @@ -15,6 +15,7 @@ gevent.monkey.patch_ssl() import os import json +from random import random from time import time from io import open from getpass import getpass @@ -263,6 +264,8 @@ class SteamClient(CMClient, BuiltinBase): if delay_seconds < maxdelay: self._reconnect_backoff_c = min(7, self._reconnect_backoff_c + 1) + delay_seconds = int(delay_seconds * 0.5 + delay_seconds * 0.5 * random()) + return self.connect(delay=delay_seconds, retry=retry) def wait_msg(self, event, timeout=None, raises=None):