mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-01-18 02:37:37 -05:00
Remove unnecessary SystemRandom from SQLBaseStore (#9987)
It's not obvious that instances of SQLBaseStore each need their own
instances of random.SystemRandom(); let's just use random directly.
Introduced by 52839886d6
Signed-off-by: Dan Callahan <danc@element.io>
This commit is contained in:
parent
ebdef256b3
commit
52ed9655ed
1
changelog.d/9987.misc
Normal file
1
changelog.d/9987.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Remove unnecessary property from SQLBaseStore.
|
@ -14,7 +14,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import logging
|
import logging
|
||||||
import random
|
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
from typing import TYPE_CHECKING, Any, Collection, Iterable, Optional, Union
|
from typing import TYPE_CHECKING, Any, Collection, Iterable, Optional, Union
|
||||||
|
|
||||||
@ -44,7 +43,6 @@ class SQLBaseStore(metaclass=ABCMeta):
|
|||||||
self._clock = hs.get_clock()
|
self._clock = hs.get_clock()
|
||||||
self.database_engine = database.engine
|
self.database_engine = database.engine
|
||||||
self.db_pool = database
|
self.db_pool = database
|
||||||
self.rand = random.SystemRandom()
|
|
||||||
|
|
||||||
def process_replication_rows(
|
def process_replication_rows(
|
||||||
self,
|
self,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
import logging
|
import logging
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
|
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
|
||||||
|
|
||||||
@ -997,7 +998,7 @@ class RegistrationWorkerStore(CacheInvalidationWorkerStore):
|
|||||||
expiration_ts = now_ms + self._account_validity_period
|
expiration_ts = now_ms + self._account_validity_period
|
||||||
|
|
||||||
if use_delta:
|
if use_delta:
|
||||||
expiration_ts = self.rand.randrange(
|
expiration_ts = random.randrange(
|
||||||
expiration_ts - self._account_validity_startup_job_max_delta,
|
expiration_ts - self._account_validity_startup_job_max_delta,
|
||||||
expiration_ts,
|
expiration_ts,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user