How to use the multiprocess.current_process function in multiprocess

To help you get started, we’ve selected a few multiprocess examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uqfoundation / multiprocess / py3.3 / multiprocess / reduction.py View on Github external
def _start(self):
        from .connection import Listener
        assert self._listener is None
        debug('starting listener and thread for sending handles')
        self._listener = Listener(authkey=current_process().authkey)
        self._address = self._listener.address
        t = threading.Thread(target=self._serve)
        t.daemon = True
        t.start()
        self._thread = t
github uqfoundation / multiprocess / py2.6 / multiprocess / reduction.py View on Github external
def _get_listener():
    global _listener

    if _listener is None:
        _lock.acquire()
        try:
            if _listener is None:
                debug('starting listener and thread for sending handles')
                _listener = Listener(authkey=current_process().authkey)
                t = threading.Thread(target=_serve)
                t.daemon = True
                t.start()
        finally:
            _lock.release()

    return _listener
github uqfoundation / multiprocess / py3.2 / examples / ex_webserver.py View on Github external
def note(format, *args):
    sys.stderr.write('[%s]\t%s\n' % (currentProcess()._name, format%args))
github uqfoundation / multiprocess / py3.3 / multiprocess / managers.py View on Github external
def RebuildProxy(func, token, serializer, kwds):
    '''
    Function used for unpickling proxy objects.

    If possible the shared object is returned, or otherwise a proxy for it.
    '''
    server = getattr(current_process(), '_manager_server', None)

    if server and server.address == token.address:
        return server.id_to_obj[token.id][0]
    else:
        incref = (
            kwds.pop('incref', True) and
            not getattr(current_process(), '_inheriting', False)
            )
        return func(token, serializer, incref=incref, **kwds)
github uqfoundation / multiprocess / py3.2 / multiprocess / managers.py View on Github external
def serve_forever(self):
        '''
        Run the server forever
        '''
        current_process()._manager_server = self
        try:
            try:
                while 1:
                    try:
                        c = self.listener.accept()
                    except (OSError, IOError):
                        continue
                    t = threading.Thread(target=self.handle_request, args=(c,))
                    t.daemon = True
                    t.start()
            except (KeyboardInterrupt, SystemExit):
                pass
        finally:
            self.stop = 999
            self.listener.close()
github uqfoundation / multiprocess / py2.6 / examples / ex_pool.py View on Github external
def calculate(func, args):
    result = func(*args)
    return '%s says that %s%s = %s' % \
        (currentProcess()._name, func.__name__, args, result)
github uqfoundation / multiprocess / py2.6 / multiprocess / reduction.py View on Github external
def rebuild_handle(pickled_data):
    address, handle, inherited = pickled_data
    if inherited:
        return handle
    sub_debug('rebuilding handle %d', handle)
    conn = Client(address, authkey=current_process().authkey)
    conn.send((handle, os.getpid()))
    new_handle = recv_handle(conn)
    conn.close()
    return new_handle
github uqfoundation / multiprocess / py2.6 / examples / ex_webserver.py View on Github external
def note(format, *args):
    sys.stderr.write('[%s]\t%s\n' % (currentProcess()._name, format%args))
github uqfoundation / multiprocess / py2.7 / examples / ex_webserver.py View on Github external
def note(format, *args):
    sys.stderr.write('[%s]\t%s\n' % (currentProcess()._name, format%args))