예제 #1
0
    def __init__(self,
                 token,
                 serializer,
                 manager=None,
                 authkey=None,
                 exposed=None,
                 incref=True):
        BaseProxy._mutex.acquire()
        try:
            tls_idset = BaseProxy._address_to_local.get(token.address, None)
            if tls_idset is None:
                tls_idset = (util.ForkAwareLocal(), ProcessLocalSet())
                BaseProxy._address_to_local[token.address] = tls_idset
        finally:
            BaseProxy._mutex.release()

        self._tls = tls_idset[0]
        self._idset = tls_idset[1]
        self._token = token
        self._id = self._token.id
        self._manager = manager
        self._serializer = serializer
        self._Client = listener_client[serializer][1]
        if authkey is not None:
            self._authkey = AuthenticationString(authkey)
        elif self._manager is not None:
            self._authkey = self._manager._authkey
        else:
            self._authkey = current_process().authkey
        if incref:
            self._incref()
        util.register_after_fork(self, BaseProxy._after_fork)
        return
예제 #2
0
 def __init__(self, address=None, authkey=None, serializer='pickle'):
     if authkey is None:
         authkey = current_process().authkey
     self._address = address     # XXX not final address if eg ('', 0)
     self._authkey = AuthenticationString(authkey)
     self._state = State()
     self._state.value = State.INITIAL
     self._serializer = serializer
     self._Listener, self._Client = listener_client[serializer]
예제 #3
0
 def __init__(self, registry, address, authkey, serializer):
     self.registry = registry
     self.authkey = AuthenticationString(authkey)
     Listener, Client = listener_client[serializer]
     self.listener = Listener(address=address, backlog=16)
     self.address = self.listener.address
     self.id_to_obj = {'0': (None, ())}
     self.id_to_refcount = {}
     self.mutex = threading.RLock()
     self.stop = 0
     return
예제 #4
0
    def __init__(self, registry, address, authkey, serializer):
        assert isinstance(authkey, bytes)
        self.registry = registry
        self.authkey = AuthenticationString(authkey)
        Listener, Client = listener_client[serializer]

        # do authentication later
        self.listener = Listener(address=address, backlog=16)
        self.address = self.listener.address

        self.id_to_obj = {'0': (None, ())}
        self.id_to_refcount = {}
        self.mutex = threading.RLock()
예제 #5
0
    def __init__(self,
                 token,
                 serializer,
                 manager=None,
                 authkey=None,
                 exposed=None,
                 incref=True,
                 manager_owned=False):
        with BaseProxy._mutex:
            tls_idset = BaseProxy._address_to_local.get(token.address, None)
            if tls_idset is None:
                tls_idset = fiber.util.ForkAwareLocal(), ProcessLocalSet()
                BaseProxy._address_to_local[token.address] = tls_idset

        # self._tls is used to record the connection used by this
        # thread to communicate with the manager at token.address
        self._tls = tls_idset[0]

        # self._idset is used to record the identities of all shared
        # objects for which the current process owns references and
        # which are in the manager at token.address
        self._idset = tls_idset[1]

        self._token = token
        self._id = self._token.id
        self._manager = manager
        self._serializer = serializer
        self._Client = listener_client[serializer][1]

        # Should be set to True only when a proxy object is being created
        # on the manager server; primary use case: nested proxy objects.
        # RebuildProxy detects when a proxy is being created on the manager
        # and sets this value appropriately.
        self._owned_by_manager = manager_owned

        if authkey is not None:
            self._authkey = AuthenticationString(authkey)
        elif self._manager is not None:
            self._authkey = self._manager._authkey
        else:
            self._authkey = process.current_process().authkey

        if incref:
            self._incref()

        fiber.util.register_after_fork(self, BaseProxy._after_fork)
예제 #6
0
파일: managers.py 프로젝트: Mshrimp/up
    def __init__(self,
                 token,
                 serializer,
                 manager=None,
                 authkey=None,
                 exposed=None,
                 incref=True):
        BaseProxy._mutex.acquire()
        try:
            tls_idset = BaseProxy._address_to_local.get(token.address, None)
            if tls_idset is None:
                tls_idset = util.ForkAwareLocal(), ProcessLocalSet()
                BaseProxy._address_to_local[token.address] = tls_idset
        finally:
            BaseProxy._mutex.release()

        # self._tls is used to record the connection used by this
        # thread to communicate with the manager at token.address
        self._tls = tls_idset[0]

        # self._idset is used to record the identities of all shared
        # objects for which the current process owns references and
        # which are in the manager at token.address
        self._idset = tls_idset[1]

        self._token = token
        self._id = self._token.id
        self._manager = manager
        self._serializer = serializer
        self._Client = listener_client[serializer][1]

        if authkey is not None:
            self._authkey = AuthenticationString(authkey)
        elif self._manager is not None:
            self._authkey = self._manager._authkey
        else:
            self._authkey = current_process().authkey

        if incref:
            self._incref()

        util.register_after_fork(self, BaseProxy._after_fork)
예제 #7
0
파일: process.py 프로젝트: pdam/WorQ
def _rebuild_connection(authkey, *args):
    current_process().authkey = AuthenticationString(authkey)
    return rebuild_connection(*args)