This commit is contained in:
zandercymatics 2023-10-11 12:58:00 -06:00
parent 1550fde832
commit af852125f8
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
6 changed files with 1131 additions and 737 deletions

View file

@ -3,6 +3,8 @@
import logging
from time import sleep
from epplibwrapper.utility.pool import EppConnectionPool
try:
from epplib.client import Client
from epplib import commands
@ -63,13 +65,22 @@ class EPPLibWrapper:
# prepare a context manager which will connect and login when invoked
# (it will also logout and disconnect when the context manager exits)
self._connect = Socket(self._client, self._login)
options = {
# Pool size
"size": 10,
# Which errors the pool should look out for
"exc_classes": (LoginError, RegistryError,),
# Should we ping the connection on occassion to keep it alive?
"keep_alive": None,
}
self._pool = EppConnectionPool(client=self._client, login=self._login, options=options)
def _send(self, command):
"""Helper function used by `send`."""
try:
cmd_type = command.__class__.__name__
with self._connect as wire:
response = wire.send(command)
with self._pool.get() as connection:
response = connection.send(command)
except (ValueError, ParsingError) as err:
message = "%s failed to execute due to some syntax error."
logger.warning(message, cmd_type, exc_info=True)