Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions 21 src/robotremoteserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, library, host='127.0.0.1', port=8270, port_file=None,
self._server = StoppableXMLRPCServer(host, int(port))
self._register_functions(self._server)
self._port_file = port_file
self._shutdown_callbacks = []
self._allow_remote_stop = allow_remote_stop \
if allow_stop == 'DEPRECATED' else allow_stop
if serve:
Expand Down Expand Up @@ -153,8 +154,28 @@ def _log(self, action, log=True, warn=False):
print('*WARN*', end=' ')
print('Robot Framework remote server at %s %s.' % (address, action))

def add_shutdown_callback(self, shutdown_callable):
""" Adds each callabel to the list of functions to be called at shutdown

:param shutdown_callable: A callabe function to call at shutdown

A callable shutdown function without arguments may be added to the
RobotRemoteServer object. When the server is asked to shutdown it will
try to call each of the shutdown functions, passing if any error occurs.
"""

if callable(shutdown_callable):
self._shutdown_callbacks.append(shutdown_callable)
else:
raise TypeError("Argument must be callable")

def stop(self):
"""Stop server."""
for callback in self._shutdown_callbacks:
try:
callback()
except:
pass
self._server.stop()

# Exposed XML-RPC methods. Should they be moved to own class?
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.