pathos.xmlrpc module documentation

server module

This module contains the base class for pathos XML-RPC servers, and derives from python’s SimpleXMLRPCServer, and the base class for XML-RPC request handlers, which derives from python’s base HTTP request handler.

Usage

A typical setup for an XML-RPC server will roughly follow this example:

>>> # establish a XML-RPC server on a host at a given port
>>> host = 'localhost'
>>> port = 1234
>>> server = XMLRPCServer(host, port)
>>> print('port=%d' % server.port)
>>>
>>> # register a method the server can handle requests for
>>> def add(x, y):
...     return x + y
>>> server.register_function(add)
>>>
>>> # activate the callback methods and begin serving requests
>>> server.activate()
>>> server.serve()

The following is an example of how to make requests to the above server:

>>> # establish a proxy connection to the server at (host,port)
>>> host = 'localhost'
>>> port = 1234
>>> proxy = xmlrpclib.ServerProxy('http://%s:%d' % (host, port))
>>> print('1 + 2 = %s' % proxy.add(1, 2))
>>> print('3 + 4 = %s' % proxy.add(3, 4))
class XMLRPCServer(host, port)

Bases: pathos.server.Server, SimpleXMLRPCServer.SimpleXMLRPCDispatcher

extends base pathos server to an XML-RPC dispatcher

create a XML-RPC server

Takes two initial inputs:
host – hostname of XML-RPC server host port – port number for server requests
__init__(host, port)

create a XML-RPC server

Takes two initial inputs:
host – hostname of XML-RPC server host port – port number for server requests
__module__ = 'pathos.xmlrpc.server'
_handleMessageFromChild(selector, fd)

handler for message from a child process

_installSocket(host, port)

prepare a listening socket

_marshaled_dispatch(data, dispatch_method=None)

override SimpleXMLRPCDispatcher._marshaled_dispatch() fault string

_onConnection(selector, fd)

upon socket connection, establish a request handler

_onSelectorIdle(selector)

something to do when there’s no requests

_onSocketConnection(socket)

upon socket connections, establish a request handler

_registerChild(pid, fromchild)

register a child process so it can be retrieved on select events

_unRegisterChild(fd)

remove a child process from active process register

activate()

install callbacks

serve()

enter the select loop… and wait for service requests

class XMLRPCRequestHandler(server, socket)

Bases: BaseHTTPServer.BaseHTTPRequestHandler

create a XML-RPC request handler

Override BaseHTTPRequestHandler.__init__(): we need to be able to have (potentially) multiple handler objects at a given time.

Inputs:
server – server object to handle requests for socket – socket connection
__init__(server, socket)

Override BaseHTTPRequestHandler.__init__(): we need to be able to have (potentially) multiple handler objects at a given time.

Inputs:
server – server object to handle requests for socket – socket connection
__module__ = 'pathos.xmlrpc.server'
_debug = <logging.Logger object>
_sendResponse(response)

Write the XML-RPC response

do_POST()

Access point from HTTP handler

log_message(format, *args)

Overriding BaseHTTPRequestHandler.log_message()