本文整理汇总了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()
示例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()
示例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)
示例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()
示例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()
示例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()
示例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')
示例8: task_done
# 需要导入模块: import queue [as 别名]
# 或者: from queue import task_done [as 别名]
def task_done(self) -> None: ...
示例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()
示例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()
示例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()
示例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
示例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()