Philipp Hörist pushed to branch master at gajim / gajim

Commits:
6ed04e2d by Philipp Hörist at 2018-05-17T21:13:37+02:00
Simplify generating random int

No need to use SystemRandom() here, as this is not needed for security
purposes

- - - - -


1 changed file:

- gajim/common/connection.py


Changes:

=====================================
gajim/common/connection.py
=====================================
--- 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)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/6ed04e2dd2d91b92dbafbdaa6e101822f0a1a148

---
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/6ed04e2dd2d91b92dbafbdaa6e101822f0a1a148
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to