/usr/lib/python3/dist-packages/landscape/lib/__pycache__
Edit: /usr/lib/python3/dist-packages/landscape/lib/__pycache__/amp.cpython-310.pyc (21783B)
o
cT @ s0 d Z ddlmZ ddlmZmZmZ ddlmZm Z ddl
mZ ddlm
Z
ddlmZmZmZmZmZmZmZ ddlmZ G d d
d
eZG dd deZG d
d deZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd deZ#G dd de Z$dS ) a> Expose the methods of a remote object over AMP.
This module implements an AMP-based protocol for performing remote procedure
calls in a convenient and easy way. It's conceptually similar to DBus in that
it supports exposing a Python object to a remote process, with communication
happening over any Twisted-supported transport, e.g. Unix domain sockets.
For example let's say we have a Python process "A" that creates an instance of
this class::
class Greeter(object):
def hello(self, name):
return "hi %s!" % name
greeter = Greeter()
Process A can "publish" the greeter object by defining which methods are
exposed remotely and opening a Unix socket for incoming connections::
factory = MethodCallServerFactory(greeter, ["hello"])
reactor.listenUNIX("/some/socket/path", factory)
Then a second Python process "B" can connect to that socket and build a
"remote" greeter object, i.e. a proxy that forwards method calls to the
real greeter object living in process A::
factory = MethodCallClientFactory()
reactor.connectUNIX("/some/socket/path", factory)
def got_remote(remote_greeter):
deferred = remote_greeter.hello("Ted")
deferred.addCallback(lambda result: ... # result == "hi Ted!")
factory.getRemoteObject().addCallback(got_remote)
Note that when invoking a method via the remote proxy, the parameters
are required to be serializable with bpickle, so they can be sent over
the wire.
See also::
http://twistedmatrix.com/documents/current/core/howto/amp.html
for more details about the Twisted AMP protocol.
)uuid4)Deferred
maybeDeferredsucceed)
ServerFactoryReconnectingClientFactory)Failure)xrange)ArgumentStringIntegerCommandAMPMAX_VALUE_LENGTHCommandLocator)bpicklec @ s, e Zd ZdZdd Zdd Zedd ZdS ) MethodCallArgumentzA bpickle-compatible argument.c C
t |S )zSerialize an argument.)r dumps)selfinObject r 3/usr/lib/python3/dist-packages/landscape/lib/amp.pytoString?
zMethodCallArgument.toStringc C r )zUnserialize an argument.)r loads)r inStringr r r
fromStringC r zMethodCallArgument.fromStringc C s t |tjv S )z%Check if an argument is serializable.)typer dumps_table)clsr r r r checkG s zMethodCallArgument.checkN)__name__
__module____qualname____doc__r r classmethodr! r r r r r <