mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39:21 +02:00
First pass EPP retry
This commit is contained in:
parent
c569db24f3
commit
4a25642d8d
4 changed files with 22 additions and 4 deletions
|
@ -17,7 +17,7 @@ except ImportError:
|
|||
from django.conf import settings
|
||||
|
||||
from .cert import Cert, Key
|
||||
from .errors import LoginError, RegistryError
|
||||
from .errors import ErrorCode, LoginError, RegistryError
|
||||
from .socket import Socket
|
||||
from .utility.pool import EPPConnectionPool
|
||||
|
||||
|
@ -115,7 +115,7 @@ class EPPLibWrapper:
|
|||
except TransportError as err:
|
||||
message = f"{cmd_type} failed to execute due to a connection error."
|
||||
logger.error(f"{message} Error: {err}", exc_info=True)
|
||||
raise RegistryError(message) from err
|
||||
raise RegistryError(message, code=ErrorCode.TRANSPORT_ERROR) from err
|
||||
except LoginError as err:
|
||||
# For linter due to it not liking this line length
|
||||
text = "failed to execute due to a registry login error."
|
||||
|
@ -159,11 +159,15 @@ class EPPLibWrapper:
|
|||
self.start_connection_pool()
|
||||
|
||||
counter = 0 # we'll try 3 times
|
||||
logger.info("Counter set to: ", counter)
|
||||
while True:
|
||||
try:
|
||||
logger.info("Trying self._send(command)")
|
||||
return self._send(command)
|
||||
except RegistryError as err:
|
||||
if err.should_retry() and counter < 3:
|
||||
logger.info("Exception found")
|
||||
if counter < 3 and (err.should_retry() or err.is_transport_error()):
|
||||
logger.info("Retrying transport error. Attempt #", counter)
|
||||
counter += 1
|
||||
sleep((counter * 50) / 1000) # sleep 50 ms to 150 ms
|
||||
else: # don't try again
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue