当前位置: 首页>>代码示例>>Python>>正文


Python util.debug函数代码示例

本文整理汇总了Python中multiprocess.util.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SocketClient

def SocketClient(address):
    '''
    Return a connection object connected to the socket given by `address`
    '''
    family = address_type(address)
    with socket.socket( getattr(socket, family) ) as s:
        s.setblocking(True)
        t = _init_timeout()

        while 1:
            try:
                s.connect(address)
            except socket.error as e:
                if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
                    debug('failed to connect to address %s', address)
                    raise
                time.sleep(0.01)
            else:
                break
        else:
            raise

        fd = duplicate(s.fileno())
    conn = _multiprocessing.Connection(fd)
    return conn
开发者ID:ximumu,项目名称:multiprocess,代码行数:25,代码来源:connection.py

示例2: _callmethod

    def _callmethod(self, methodname, args=(), kwds={}):
        '''
        Try to call a method of the referrent and return a copy of the result
        '''
        try:
            conn = self._tls.connection
        except AttributeError:
            util.debug('thread %r does not own a connection',
                       threading.current_thread().name)
            self._connect()
            conn = self._tls.connection

        conn.send((self._id, methodname, args, kwds))
        kind, result = conn.recv()

        if kind == '#RETURN':
            return result
        elif kind == '#PROXY':
            exposed, token = result
            proxytype = self._manager._registry[token.typeid][-1]
            proxy = proxytype(
                token, self._serializer, manager=self._manager,
                authkey=self._authkey, exposed=exposed
                )
            conn = self._Client(token.address, authkey=self._authkey)
            dispatch(conn, None, 'decref', (token.id,))
            return proxy
        raise convert_to_error(kind, result)
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:28,代码来源:managers.py

示例3: worker

def worker(inqueue, outqueue, initializer=None, initargs=()):
    put = outqueue.put
    get = inqueue.get
    if hasattr(inqueue, '_writer'):
        inqueue._writer.close()
        outqueue._reader.close()

    if initializer is not None:
        initializer(*initargs)

    while 1:
        try:
            task = get()
        except (EOFError, IOError):
            debug('worker got EOFError or IOError -- exiting')
            break

        if task is None:
            debug('worker got sentinel -- exiting')
            break

        job, i, func, args, kwds = task
        try:
            result = (True, func(*args, **kwds))
        except Exception, e:
            result = (False, e)
        put((job, i, result))
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:27,代码来源:pool.py

示例4: join

 def join(self):
     debug('joining pool')
     assert self._state in (CLOSE, TERMINATE)
     self._task_handler.join()
     self._result_handler.join()
     for p in self._pool:
         p.join()
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:7,代码来源:pool.py

示例5: cancel_join_thread

 def cancel_join_thread(self):
     debug('Queue.cancel_join_thread()')
     self._joincancelled = True
     try:
         self._jointhread.cancel()
     except AttributeError:
         pass
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:7,代码来源:queues.py

示例6: _help_stuff_finish

 def _help_stuff_finish(inqueue, task_handler, size):
     # task_handler may be blocked trying to put items on inqueue
     debug('removing tasks from inqueue until task handler finished')
     inqueue._rlock.acquire()
     while task_handler.is_alive() and inqueue._reader.poll():
         inqueue._reader.recv()
         time.sleep(0)
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:7,代码来源:pool.py

示例7: _finalize_close

 def _finalize_close(buffer, notempty):
     debug('telling queue thread to quit')
     notempty.acquire()
     try:
         buffer.append(_sentinel)
         notempty.notify()
     finally:
         notempty.release()
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:8,代码来源:queues.py

示例8: _connect

 def _connect(self):
     util.debug('making connection to manager')
     name = current_process().name
     if threading.current_thread().name != 'MainThread':
         name += '|' + threading.current_thread().name
     conn = self._Client(self._token.address, authkey=self._authkey)
     dispatch(conn, None, 'accept_connection', (name,))
     self._tls.connection = conn
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:8,代码来源:managers.py

示例9: __init__

    def __init__(self, kind, value, maxvalue):
        sl = self._semlock = _multiprocessing.SemLock(kind, value, maxvalue)
        debug('created semlock with handle %s' % sl.handle)
        self._make_methods()

        if sys.platform != 'win32':
            def _after_fork(obj):
                obj._semlock._after_fork()
            register_after_fork(self, _after_fork)
开发者ID:ximumu,项目名称:multiprocess,代码行数:9,代码来源:synchronize.py

示例10: _feed

    def _feed(buffer, notempty, send, writelock, close, ignore_epipe):
        debug('starting thread to feed data to pipe')
        from .util import is_exiting

        nacquire = notempty.acquire
        nrelease = notempty.release
        nwait = notempty.wait
        bpopleft = buffer.popleft
        sentinel = _sentinel
        if sys.platform != 'win32':
            wacquire = writelock.acquire
            wrelease = writelock.release
        else:
            wacquire = None

        try:
            while 1:
                nacquire()
                try:
                    if not buffer:
                        nwait()
                finally:
                    nrelease()
                try:
                    while 1:
                        obj = bpopleft()
                        if obj is sentinel:
                            debug('feeder thread got sentinel -- exiting')
                            close()
                            return

                        if wacquire is None:
                            send(obj)
                        else:
                            wacquire()
                            try:
                                send(obj)
                            finally:
                                wrelease()
                except IndexError:
                    pass
        except Exception as e:
            if ignore_epipe and getattr(e, 'errno', 0) == errno.EPIPE:
                return
            # Since this runs in a daemon thread the resources it uses
            # may be become unusable while the process is cleaning up.
            # We ignore errors which happen after the process has
            # started to cleanup.
            try:
                if is_exiting():
                    info('error in queue thread: %s', e)
                else:
                    import traceback
                    traceback.print_exc()
            except Exception:
                pass
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:56,代码来源:queues.py

示例11: _start

 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
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:10,代码来源:reduction.py

示例12: temp

 def temp(self, *args, **kwds):
     util.debug('requesting creation of a shared %r object', typeid)
     token, exp = self._create(typeid, *args, **kwds)
     proxy = proxytype(
         token, self._serializer, manager=self,
         authkey=self._authkey, exposed=exp
         )
     conn = self._Client(token.address, authkey=self._authkey)
     dispatch(conn, None, 'decref', (token.id,))
     return proxy
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:10,代码来源:managers.py

示例13: decref

 def decref(self, c, ident):
     self.mutex.acquire()
     try:
         assert self.id_to_refcount[ident] >= 1
         self.id_to_refcount[ident] -= 1
         if self.id_to_refcount[ident] == 0:
             del self.id_to_obj[ident], self.id_to_refcount[ident]
             util.debug('disposing of obj with id %r', ident)
     finally:
         self.mutex.release()
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:10,代码来源:managers.py

示例14: _handle_workers

    def _handle_workers(pool):
        thread = threading.current_thread()

        # Keep maintaining workers until the cache gets drained, unless the pool
        # is terminated.
        while thread._state == RUN or (pool._cache and thread._state != TERMINATE):
            pool._maintain_pool()
            time.sleep(0.1)
        # send sentinel to stop workers
        pool._taskqueue.put(None)
        debug('worker handler exiting')
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:11,代码来源:pool.py

示例15: _decref

    def _decref(token, authkey, state, tls, idset, _Client):
        idset.discard(token.id)

        # check whether manager is still alive
        if state is None or state.value == State.STARTED:
            # tell manager this process no longer cares about referent
            try:
                util.debug('DECREF %r', token.id)
                conn = _Client(token.address, authkey=authkey)
                dispatch(conn, None, 'decref', (token.id,))
            except Exception, e:
                util.debug('... decref failed %s', e)
开发者ID:ximumu,项目名称:multiprocess,代码行数:12,代码来源:managers.py


注:本文中的multiprocess.util.debug函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。