• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.debug函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _after_fork

 def _after_fork(self):
     debug('Queue._after_fork()')
     self._notempty = threading.Condition(threading.Lock())
     self._buffer = collections.deque()
     self._thread = None
     self._jointhread = None
     self._joincancelled = False
     self._closed = False
     self._close = None
     self._send = self._writer.send
     self._recv = self._reader.recv
     self._poll = self._reader.poll
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:12,代码来源:queues.py


示例17: shutdown

 def shutdown(self, c):
     '''
     Shutdown this process
     '''
     try:
         util.debug('manager received shutdown message')
         c.send(('#RETURN', None))
     except:
         import traceback
         traceback.print_exc()
     finally:
         self.stop_event.set()
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:12,代码来源:managers.py


示例18: _join_exited_workers

 def _join_exited_workers(self):
     """Cleanup after any worker processes which have exited due to reaching
     their specified lifetime.  Returns True if any workers were cleaned up.
     """
     cleaned = False
     for i in reversed(range(len(self._pool))):
         worker = self._pool[i]
         if worker.exitcode is not None:
             # worker exited
             debug('cleaning up worker %d' % i)
             worker.join()
             cleaned = True
             del self._pool[i]
     return cleaned
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:14,代码来源:pool.py


示例19: shutdown

    def shutdown(self, c):
        '''
        Shutdown this process
        '''
        try:
            try:
                util.debug('manager received shutdown message')
                c.send(('#RETURN', None))

                if sys.stdout != sys.__stdout__:
                    util.debug('resetting stdout, stderr')
                    sys.stdout = sys.__stdout__
                    sys.stderr = sys.__stderr__

                util._run_finalizers(0)

                for p in active_children():
                    util.debug('terminating a child process of manager')
                    p.terminate()

                for p in active_children():
                    util.debug('terminating a child process of manager')
                    p.join()

                util._run_finalizers()
                util.info('manager exiting with exitcode 0')
            except:
                import traceback
                traceback.print_exc()
        finally:
            exit(0)
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:31,代码来源:managers.py


示例20: _repopulate_pool

 def _repopulate_pool(self):
     """Bring the number of pool processes up to the specified number,
     for use after reaping workers which have exited.
     """
     for i in range(self._processes - len(self._pool)):
         w = self.Process(target=worker,
                          args=(self._inqueue, self._outqueue,
                                self._initializer,
                                self._initargs, self._maxtasksperchild)
                         )
         self._pool.append(w)
         w.name = w.name.replace('Process', 'PoolWorker')
         w.daemon = True
         w.start()
         debug('added worker')
开发者ID:uqfoundation,项目名称:multiprocess,代码行数:15,代码来源:pool.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python multiprocessing.active_children函数代码示例发布时间:2022-05-27
下一篇:
Python multiprocess.Pool类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap