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


Python queue.task_done方法代码示例

本文整理汇总了Python中queue.task_done方法的典型用法代码示例。如果您正苦于以下问题:Python queue.task_done方法的具体用法?Python queue.task_done怎么用?Python queue.task_done使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在queue的用法示例。


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

示例1: consumer

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def consumer(queue, stack, apix=1.0, iothreads=None):
    log = logging.getLogger('root')
    with mrc.ZSliceWriter(stack, psz=apix) as zwriter:
        while True:
            log.debug("Get")
            i, ri = queue.get(block=True)
            log.debug("Got %d, queue for %s is size %d" %
                      (i, stack, queue.qsize()))
            if i == -1:
                break
            new_image = ri.get()
            log.debug("Result for %d was shape (%d,%d)" %
                      (i, new_image.shape[0], new_image.shape[1]))
            zwriter.write(new_image)
            queue.task_done()
            log.debug("Wrote %d to %d@%s" % (i, zwriter.i, stack))
    if iothreads is not None:
        iothreads.release() 
开发者ID:asarnow,项目名称:pyem,代码行数:20,代码来源:projection_subtraction.py

示例2: myTask

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def myTask(queue):
  value = queue.get()
  print("Process {} Popped {} from the shared Queue".format(multiprocessing.current_process().pid, value))
  queue.task_done() 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:6,代码来源:mpQueue.py

示例3: mySubscriber

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def mySubscriber(queue):
  while not queue.empty():
    item = queue.get()
    if item is None:
      break
    print("{} removed {} from the queue".format(threading.current_thread(), item))
    queue.task_done()
    time.sleep(1) 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:10,代码来源:queues.py

示例4: mySubscriber

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def mySubscriber(queue):
  while True:
    item = queue.get()
    if item is None:
      break
    print("{} removed {} from the queue".format(threading.current_thread(), item))
    print("Queue Size is now: {}".format(queue.qsize()))
    queue.task_done() 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:10,代码来源:queueOperations.py

示例5: mySubscriber

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def mySubscriber(queue):
  while not queue.empty():
    item = queue.get()
    if item is None:
      break
    print("{} removed {} from the queue".format(threading.current_thread(), item))
    queue.task_done() 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:9,代码来源:lifoQueues.py

示例6: mySubscriber

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def mySubscriber(queue):
  time.sleep(1)
  while not queue.empty():
    item = queue.get()
    if item is None:
      break
    print("{} removed {} from the queue".format(threading.current_thread(), item))
    queue.task_done() 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:10,代码来源:queueJoin.py

示例7: worker

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def worker(c):
    thread = threading.currentThread()
    if queue.empty():
        return
    json_file = queue.get()
    config = json_file.replace(".json","")
    c.run(config)
    worker(c)
    queue.task_done()
    logging.debug('Done') 
开发者ID:HyperGAN,项目名称:HyperGAN,代码行数:12,代码来源:run_all.py

示例8: task_done

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def task_done(self) -> None: ... 
开发者ID:wikimedia,项目名称:search-MjoLniR,代码行数:3,代码来源:msearch_daemon.py

示例9: iter_queue

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def iter_queue(queue: TypedQueue[Optional[T]]) -> Generator[T, None, None]:
    """Yield items from a queue"""
    while True:
        record = queue.get()
        try:
            # Queue is finished, nothing more will arrive
            if record is None:
                return
            yield record
        finally:
            queue.task_done() 
开发者ID:wikimedia,项目名称:search-MjoLniR,代码行数:13,代码来源:msearch_daemon.py

示例10: run

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def run(self):
        while True:
            im = queue.get()
            if im is None:
                queue.task_done()
                sys.stdout.write("x")
                break
            f = io.BytesIO()
            im.save(f, test_format, optimize=1)
            data = f.getvalue()
            result.append(len(data))
            im = Image.open(io.BytesIO(data))
            im.load()
            sys.stdout.write(".")
            queue.task_done() 
开发者ID:holzschu,项目名称:python3_ios,代码行数:17,代码来源:threaded_save.py

示例11: request_task

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def request_task(self, queue, setup_or_state_change_or_validation, test_functions, test_iteration):
        try:
            # Table data does not provide ability to inject unique agent_id's for each concurrent instance.
            # The queue stores unique agent_id objects, injected by the new_thread function.
            # Get the agent_id from the Queue and modify the original table data to change the agent_id to something unique.
            http_request_body_tag = test_functions.get("http_request_body")
            http_request_body_file_tag = test_functions.get("http_request_body_file")
            if http_request_body_tag != None and http_request_body_file_tag != None :
                self.fail("Test " + self._testMethodName + ":" + test_functions["function_name"] + " contains both http_request_body and http_request_body_file tags." )

            thedata = ''
            if http_request_body_tag == None and http_request_body_file_tag != None:
                thedata = open(http_request_body_file_tag).read()
            else:
                thedata=http_request_body_tag

            the_uid = queue.get()
            jsondata = json.loads(thedata)
            jsondata['agent_id'] = the_uid
            newdata = json.dumps(jsondata)

            # call the inline task passing the new data with the unique agent_id
            self.execute_the_test(setup_or_state_change_or_validation, test_functions, test_iteration )

        except Exception as e:
            self.fail("Test " + self._testMethodName + ":" + test_functions["function_name"] + ", unexpected exception error: %s"%e )
        finally:
            queue.task_done() 
开发者ID:keylime,项目名称:keylime,代码行数:30,代码来源:oldtest.py

示例12: download_worker

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def download_worker():
    while True:
        url = queue.get()
        download_file(url, SAVE_DIR)
        queue.task_done()

# Returns the path of the specified page number 
开发者ID:benjaminheng,项目名称:interfacelift-downloader,代码行数:9,代码来源:interfacelift-downloader.py

示例13: write_buffer

# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def write_buffer(buffer):
    for item in buffer:
        try:
            item['fn'](*item.get('args', ()), **item.get('kw', {}))
        except:
            log.exception(
                'Exception while processing queue item: {}'
                .format(item))
        queue.task_done() 
开发者ID:anqxyr,项目名称:pyscp,代码行数:11,代码来源:orm.py


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