def transact(address, authkey, methodname, args=(), kwds={}): ''' Create connection then send a message to manager and return response ''' conn = Client(address, authkey=authkey) try: return dispatch(conn, None, methodname, args, kwds) finally: conn.close()
def rebuildHandle(pickled_data): from processing.connection import Client address, handle, inherited = pickled_data if inherited: return handle subDebug('rebuilding handle %d', handle) conn = Client(address, authenticate=True) conn.send((handle, os.getpid())) new_handle = recvHandle(conn) conn.close() return new_handle
def _connect(self): debug('making connection to manager') name = currentProcess().getName() if threading.currentThread().getName() != 'MainThread': name += '|' + threading.currentThread().getName() connection = Client(self._token.address, authkey=self._authkey) dispatch(connection, None, 'acceptConnection', (name, )) self._tls.connection = connection
def _decref(token, authkey, shutdown, tls, idset): idset.remove(token.id) # check whether manager is still alive manager_still_alive = shutdown is None or shutdown.stillActive() if manager_still_alive: # tell manager this process no longer cares about referent try: debug('DECREF %r', token.id) connection = Client(token.address, authkey=authkey) dispatch(connection, None, 'decref', (token.id, )) except (SystemExit, KeyboardInterrupt): raise except Exception, e: debug('... decref failed %s', e)
def _incref(self): connection = Client(self._token.address, authkey=self._authkey) dispatch(connection, None, 'incref', (self._id, )) debug('INCREF %r', self._token.id) assert self._id not in self._idset self._idset.add(self._id) shutdown = getattr(self._manager, 'shutdown', None) self._close = Finalize(self, BaseProxy._decref, args=(self._token, self._authkey, shutdown, self._tls, self._idset), exitpriority=10)