From 6ed04e2dd2d91b92dbafbdaa6e101822f0a1a148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Thu, 17 May 2018 21:13:37 +0200 Subject: [PATCH] Simplify generating random int No need to use SystemRandom() here, as this is not needed for security purposes --- gajim/common/connection.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/gajim/common/connection.py b/gajim/common/connection.py index ea0a8e6e3..68dc563ac 100644 --- a/gajim/common/connection.py +++ b/gajim/common/connection.py @@ -49,12 +49,6 @@ from string import Template from urllib.request import urlopen from urllib.error import URLError -try: - randomsource = random.SystemRandom() -except Exception: - randomsource = random.Random() - randomsource.seed() - if os.name == 'nt': import certifi import OpenSSL.crypto @@ -805,7 +799,7 @@ class Connection(CommonConnection, ConnectionHandlers): # do exponential backoff until less than 5 minutes if self.retrycount < 2 or self.last_time_to_reconnect is None: self.last_time_to_reconnect = 5 - self.last_time_to_reconnect += randomsource.randint(0, 5) + self.last_time_to_reconnect += random.randint(0, 5) if self.last_time_to_reconnect < 200: self.last_time_to_reconnect *= 1.5 self.time_to_reconnect = int(self.last_time_to_reconnect)