Commit 6ed04e2d authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Simplify generating random int

No need to use SystemRandom() here, as this is not needed for security
purposes
parent 4731e849
......@@ -49,12 +49,6 @@
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 @@ def disconnectedReconnCB(self):
# 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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment