Skip to content

Commit

Permalink
Removed method rpc_exception_handler which is not needed anymore sinc…
Browse files Browse the repository at this point in the history
…e newly implemented timeout mechanic for RPC
  • Loading branch information
Galoshi committed Mar 27, 2024
1 parent f66a283 commit b07a070
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions source/rpc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,3 @@ def wrapper(self, *args, **kwargs):
warnings.warn(message, UserWarning)
return function(self, *args, **kwargs)
return wrapper


def rpc_exception_handler(max_timeout):
"""Timeout decorator, parameter in seconds."""

def exception_decorator(item):
"""Wrap the original function."""

@functools.wraps(item)
def func_wrapper(*args, **kwargs):
"""Closure for function."""
try:
pool = multiprocessing.pool.ThreadPool(processes=1)
async_result = pool.apply_async(item, args, kwargs)
# raises a TimeoutError if execution exceeds max_timeout
pool.close()
return async_result.get(max_timeout)

except multiprocessing.context.TimeoutError as e:
raise TimeoutError(
"Unable to establish XML-RPC connection to device with IP {}. "
"Execution time exceeded max timeout of {} seconds."
.format(args[0].address, max_timeout))

return func_wrapper

return exception_decorator

0 comments on commit b07a070

Please sign in to comment.