當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。