當前位置: 首頁>>代碼示例>>Python>>正文


Python queues.SimpleQueue方法代碼示例

本文整理匯總了Python中multiprocessing.queues.SimpleQueue方法的典型用法代碼示例。如果您正苦於以下問題:Python queues.SimpleQueue方法的具體用法?Python queues.SimpleQueue怎麽用?Python queues.SimpleQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在multiprocessing.queues的用法示例。


在下文中一共展示了queues.SimpleQueue方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SimpleQueue

# 需要導入模塊: from multiprocessing import queues [as 別名]
# 或者: from multiprocessing.queues import SimpleQueue [as 別名]
def SimpleQueue():
    '''
    Returns a queue object
    '''
    from multiprocessing.queues import SimpleQueue
    return SimpleQueue() 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:8,代碼來源:__init__.py

示例2: put

# 需要導入模塊: from multiprocessing import queues [as 別名]
# 或者: from multiprocessing.queues import SimpleQueue [as 別名]
def put(self, obj):
        bytes = pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL)
        # follow SimpleQueue, need to deal with _wlock being None
        if self._wlock is None:
            self._writer.send_bytes(bytes)
        else:
            with self._wlock:
                self._writer.send_bytes(bytes) 
開發者ID:lenskit,項目名稱:lkpy,代碼行數:10,代碼來源:parallel.py

示例3: SimpleQueue

# 需要導入模塊: from multiprocessing import queues [as 別名]
# 或者: from multiprocessing.queues import SimpleQueue [as 別名]
def SimpleQueue(self):
        return FastQ(ctx=self.get_context()) 
開發者ID:lenskit,項目名稱:lkpy,代碼行數:4,代碼來源:parallel.py

示例4: run_sp

# 需要導入模塊: from multiprocessing import queues [as 別名]
# 或者: from multiprocessing.queues import SimpleQueue [as 別名]
def run_sp(func, *args, **kwargs):
    """
    Run a function in a subprocess and return its value.  This is for achieving subprocess
    isolation, not parallelism.  The subprocess is configured so things like logging work
    correctly, and is initialized with a derived random seed.
    """
    ctx = LKContext.INSTANCE
    rq = ctx.SimpleQueue()
    seed = derive_seed(none_on_old_numpy=True)
    worker_args = (log_queue(), seed, rq, func, args, kwargs)
    _log.debug('spawning subprocess to run %s', func)
    proc = ctx.Process(target=_sp_worker, args=worker_args)
    proc.start()
    _log.debug('waiting for process %s to return', proc)
    success, payload = rq.get()
    _log.debug('received success=%s', success)
    _log.debug('waiting for process %s to exit', proc)
    proc.join()
    if proc.exitcode:
        _log.error('subprocess failed with code %d', proc.exitcode)
        raise RuntimeError('subprocess failed with code ' + str(proc.exitcode))
    if success:
        return payload
    else:
        _log.error('subprocess raised exception: %s', payload)
        raise ChildProcessError('error in child process', payload) 
開發者ID:lenskit,項目名稱:lkpy,代碼行數:28,代碼來源:parallel.py


注:本文中的multiprocessing.queues.SimpleQueue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。