libgs.rpc.RPCServer

class libgs.rpc.RPCServer(uri, logRequests=False, allow_none=True, start=True)[source]

Drop-in replacement for SimpleXMLRPCServer.SimpleXMLRPCServer that supports kwargs.

It also allows the address to be specified as a uri, http://hostname:port instead of (hostname,port), but the latter is also supported for full SimpleXMLRPCServer.SimpleXMLRPCServer compatability.

Finally, it allows you to call register_function in the same way as for SimpleXMLRPCServer, but it also allows you to use it as a decorator.

So these two are equivalent:

>>> s = RPCServer()
>>> @s.register_function
>>> def blah()
>>>    print("blah")
>>> s = RPCServer()
>>> def blah()
>>>     print("blah")
>>> s.register_function(blah)
Parameters:

Methods

register_function(function[, name])
register_instance(instance[, allow_dotted_names])
serve_forever([poll_interval])
start()
stop()

Attributes

is_serving Returns True if the

Inherited from base class

close_request(request) Called to clean up an individual request.
fileno() Return socket file number.
finish_request(request, client_address) Finish one request by instantiating RequestHandlerClass.
get_request() Get the request and client address from the socket.
handle_error(request, client_address) Handle an error gracefully.
handle_request() Handle one request, possibly blocking.
handle_timeout() Called if no new request arrives within self.timeout.
process_request(request, client_address) Call finish_request.
register_introspection_functions() Registers the XML-RPC introspection methods in the system namespace.
register_multicall_functions() Registers the XML-RPC multicall method in the system namespace.
server_activate() Called by constructor to activate the server.
server_bind() Called by constructor to bind the socket.
server_close() Called to clean-up the server.
shutdown() Stops the serve_forever loop.
shutdown_request(request) Called to shutdown and close an individual request.
system_listMethods() system.listMethods() => [‘add’, ‘subtract’, ‘multiple’]
system_methodHelp(method_name) system.methodHelp(‘add’) => “Adds two integers together”
system_methodSignature(method_name) system.methodSignature(‘add’) => [double, int, int]
system_multicall(call_list) system.multicall([{‘methodName’: ‘add’, ‘params’: [2, 2]}, …]) => [[4], …]
verify_request(request, client_address) Verify the request.
address_family
allow_reuse_address
request_queue_size
socket_type
timeout