Simplify generating random int

No need to use SystemRandom() here, as this is not needed for security
purposes
This commit is contained in:
Philipp Hörist 2018-05-17 21:13:37 +02:00
parent 4731e8491b
commit 6ed04e2dd2
1 changed files with 1 additions and 7 deletions

View File

@ -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)