Back to index

python3.2  3.2.2
Classes | Functions | Variables
multiprocessing.managers Namespace Reference

Classes

class  Token
class  RemoteError
class  Server
class  State
class  BaseManager
class  ProcessLocalSet
class  BaseProxy
class  Namespace
class  Value
class  IteratorProxy
class  AcquirerProxy
class  ConditionProxy
class  EventProxy
class  NamespaceProxy
class  ValueProxy
class  ListProxy
class  SyncManager

Functions

def reduce_array
def rebuild_as_list
def dispatch
def convert_to_error
def all_methods
def public_methods
def RebuildProxy
def MakeProxyType
def AutoProxy
def Array

Variables

list __all__ = [ 'BaseManager', 'SyncManager', 'BaseProxy', 'Token' ]
list view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]
dictionary listener_client
tuple BaseListProxy
tuple DictProxy
tuple ArrayProxy
tuple PoolProxy

Function Documentation

Return a list of names of methods of `obj`

Definition at line 130 of file managers.py.

00130 
00131 def all_methods(obj):
00132     '''
00133     Return a list of names of methods of `obj`
00134     '''
00135     temp = []
00136     for name in dir(obj):
00137         func = getattr(obj, name)
00138         if hasattr(func, '__call__'):
00139             temp.append(name)
00140     return temp

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.managers.Array (   typecode,
  sequence,
  lock = True 
)

Definition at line 962 of file managers.py.

00962 
00963 def Array(typecode, sequence, lock=True):
00964     return array.array(typecode, sequence)
00965 
00966 #
00967 # Proxy types used by SyncManager
00968 #

def multiprocessing.managers.AutoProxy (   token,
  serializer,
  manager = None,
  authkey = None,
  exposed = None,
  incref = True 
)
Return an auto-proxy for `token`

Definition at line 910 of file managers.py.

00910 
00911               exposed=None, incref=True):
00912     '''
00913     Return an auto-proxy for `token`
00914     '''
00915     _Client = listener_client[serializer][1]
00916 
00917     if exposed is None:
00918         conn = _Client(token.address, authkey=authkey)
00919         try:
00920             exposed = dispatch(conn, None, 'get_methods', (token,))
00921         finally:
00922             conn.close()
00923 
00924     if authkey is None and manager is not None:
00925         authkey = manager._authkey
00926     if authkey is None:
00927         authkey = current_process().authkey
00928 
00929     ProxyType = MakeProxyType('AutoProxy[%s]' % token.typeid, exposed)
00930     proxy = ProxyType(token, serializer, manager=manager, authkey=authkey,
00931                       incref=incref)
00932     proxy._isauto = True
00933     return proxy
00934 
00935 #
00936 # Types/callables which we will register with SyncManager
00937 #

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.managers.convert_to_error (   kind,
  result 
)

Definition at line 110 of file managers.py.

00110 
00111 def convert_to_error(kind, result):
00112     if kind == '#ERROR':
00113         return result
00114     elif kind == '#TRACEBACK':
00115         assert type(result) is str
00116         return  RemoteError(result)
00117     elif kind == '#UNSERIALIZABLE':
00118         assert type(result) is str
00119         return RemoteError('Unserializable message: %s\n' % result)
00120     else:
00121         return ValueError('Unrecognized message type')

Here is the caller graph for this function:

def multiprocessing.managers.dispatch (   c,
  id,
  methodname,
  args = (),
  kwds = {} 
)
Send a message to manager using connection `c` and return response

Definition at line 100 of file managers.py.

00100 
00101 def dispatch(c, id, methodname, args=(), kwds={}):
00102     '''
00103     Send a message to manager using connection `c` and return response
00104     '''
00105     c.send((id, methodname, args, kwds))
00106     kind, result = c.recv()
00107     if kind == '#RETURN':
00108         return result
00109     raise convert_to_error(kind, result)

Here is the call graph for this function:

Here is the caller graph for this function:

def multiprocessing.managers.MakeProxyType (   name,
  exposed,
  _cache = {} 
)
Return an proxy type whose methods are given by `exposed`

Definition at line 887 of file managers.py.

00887 
00888 def MakeProxyType(name, exposed, _cache={}):
00889     '''
00890     Return an proxy type whose methods are given by `exposed`
00891     '''
00892     exposed = tuple(exposed)
00893     try:
00894         return _cache[(name, exposed)]
00895     except KeyError:
00896         pass
00897 
00898     dic = {}
00899 
00900     for meth in exposed:
00901         exec('''def %s(self, *args, **kwds):
00902         return self._callmethod(%r, args, kwds)''' % (meth, meth), dic)
00903 
00904     ProxyType = type(name, (BaseProxy,), dic)
00905     ProxyType._exposed_ = exposed
00906     _cache[(name, exposed)] = ProxyType
00907     return ProxyType
00908 

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of names of methods of `obj` which do not start with '_'

Definition at line 141 of file managers.py.

00141 
00142 def public_methods(obj):
00143     '''
00144     Return a list of names of methods of `obj` which do not start with '_'
00145     '''
00146     return [name for name in all_methods(obj) if name[0] != '_']
00147 
00148 #
00149 # Server which is run in a process controlled by a manager
00150 #

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 66 of file managers.py.

00066 
00067     def rebuild_as_list(obj):
        return list, (list(obj),)

Here is the call graph for this function:

def multiprocessing.managers.RebuildProxy (   func,
  token,
  serializer,
  kwds 
)
Function used for unpickling proxy objects.

If possible the shared object is returned, or otherwise a proxy for it.

Definition at line 866 of file managers.py.

00866 
00867 def RebuildProxy(func, token, serializer, kwds):
00868     '''
00869     Function used for unpickling proxy objects.
00870 
00871     If possible the shared object is returned, or otherwise a proxy for it.
00872     '''
00873     server = getattr(current_process(), '_manager_server', None)
00874 
00875     if server and server.address == token.address:
00876         return server.id_to_obj[token.id][0]
00877     else:
00878         incref = (
00879             kwds.pop('incref', True) and
00880             not getattr(current_process(), '_inheriting', False)
00881             )
00882         return func(token, serializer, incref=incref, **kwds)
00883 
00884 #
00885 # Functions to create proxies and proxy types
00886 #

Here is the call graph for this function:

Definition at line 60 of file managers.py.

00060 
00061 def reduce_array(a):
00062     return array.array, (a.typecode, a.tobytes())
00063 ForkingPickler.register(array.array, reduce_array)


Variable Documentation

Definition at line 36 of file managers.py.

Initial value:
00001 MakeProxyType('ArrayProxy', (
00002     '__len__', '__getitem__', '__setitem__', '__getslice__', '__setslice__'
00003     ))

Definition at line 1066 of file managers.py.

Initial value:
00001 MakeProxyType('BaseListProxy', (
00002     '__add__', '__contains__', '__delitem__', '__delslice__',
00003     '__getitem__', '__getslice__', '__len__', '__mul__',
00004     '__reversed__', '__rmul__', '__setitem__', '__setslice__',
00005     'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
00006     'reverse', 'sort', '__imul__'
00007     ))

Definition at line 1043 of file managers.py.

Initial value:
00001 MakeProxyType('DictProxy', (
00002     '__contains__', '__delitem__', '__getitem__', '__len__',
00003     '__setitem__', 'clear', 'copy', 'get', 'has_key', 'items',
00004     'keys', 'pop', 'popitem', 'setdefault', 'update', 'values'
00005     ))

Definition at line 1059 of file managers.py.

Initial value:
00001 {
00002     'pickle' : (connection.Listener, connection.Client),
00003     'xmlrpclib' : (connection.XmlListener, connection.XmlClient)
00004     }

Definition at line 460 of file managers.py.

Initial value:
00001 MakeProxyType('PoolProxy', (
00002     'apply', 'apply_async', 'close', 'imap', 'imap_unordered', 'join',
00003     'map', 'map_async', 'terminate'
00004     ))

Definition at line 1071 of file managers.py.

list multiprocessing.managers.view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]

Definition at line 64 of file managers.py.