mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-11 20:19:38 +02:00
Add settings for pooling, keep_alive
This commit is contained in:
parent
a02d27aaec
commit
3a28a3a362
3 changed files with 28 additions and 9 deletions
|
@ -1,9 +1,13 @@
|
|||
import logging
|
||||
from geventconnpool import ConnectionPool
|
||||
from epplibwrapper import RegistryError
|
||||
from epplibwrapper.errors import LoginError
|
||||
from epplibwrapper.errors import RegistryError, LoginError
|
||||
from epplibwrapper.socket import Socket
|
||||
|
||||
try:
|
||||
from epplib.commands import Hello
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class EppConnectionPool(ConnectionPool):
|
||||
|
@ -20,11 +24,17 @@ class EppConnectionPool(ConnectionPool):
|
|||
return connection
|
||||
except LoginError as err:
|
||||
message = "_new_connection failed to execute due to a registry login error."
|
||||
logger.warning(message, exc_info=True)
|
||||
logger.error(message, exc_info=True)
|
||||
raise RegistryError(message) from err
|
||||
|
||||
def _keepalive(self, connection):
|
||||
pass
|
||||
def _keepalive(self, c):
|
||||
"""Sends a command to the server to keep the connection alive."""
|
||||
try:
|
||||
# Sends a ping to EPPLib
|
||||
c.send(Hello())
|
||||
except Exception as err:
|
||||
logger.error("Failed to keep the connection alive.", exc_info=True)
|
||||
raise RegistryError("Failed to keep the connection alive.") from err
|
||||
|
||||
def create_socket(self, client, login) -> Socket:
|
||||
"""Creates and returns a socket instance"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue