Merge pull request #5936 from FinnStutzenstein/redisTimeoutErrors
Attempt on handling timeout errors
This commit is contained in:
commit
265145f001
@ -1,4 +1,5 @@
|
|||||||
# type: ignore
|
# type: ignore
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from asgiref.sync import async_to_sync
|
from asgiref.sync import async_to_sync
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@ -33,7 +34,16 @@ class SessionStore(SessionBase):
|
|||||||
return salted_hmac(key_salt, value).hexdigest()
|
return salted_hmac(key_salt, value).hexdigest()
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
return async_to_sync(self._load)()
|
retries = 0
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return async_to_sync(self._load)()
|
||||||
|
except TimeoutError as e:
|
||||||
|
if retries < 3:
|
||||||
|
sleep(0.1)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
retries += 1
|
||||||
|
|
||||||
async def _load(self):
|
async def _load(self):
|
||||||
async with get_connection(read_only=True) as redis:
|
async with get_connection(read_only=True) as redis:
|
||||||
|
Loading…
Reference in New Issue
Block a user