Python queue.task_done() Examples
The following are 13
code examples of queue.task_done().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
queue
, or try the search function
.
Example #1
Source File: projection_subtraction.py From pyem with GNU General Public License v3.0 | 6 votes |
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()
Example #2
Source File: mpQueue.py From Learning-Concurrency-in-Python with MIT License | 5 votes |
def myTask(queue): value = queue.get() print("Process {} Popped {} from the shared Queue".format(multiprocessing.current_process().pid, value)) queue.task_done()
Example #3
Source File: queues.py From Learning-Concurrency-in-Python with MIT License | 5 votes |
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)
Example #4
Source File: queueOperations.py From Learning-Concurrency-in-Python with MIT License | 5 votes |
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()
Example #5
Source File: lifoQueues.py From Learning-Concurrency-in-Python with MIT License | 5 votes |
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()
Example #6
Source File: queueJoin.py From Learning-Concurrency-in-Python with MIT License | 5 votes |
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()
Example #7
Source File: run_all.py From HyperGAN with MIT License | 5 votes |
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')
Example #8
Source File: msearch_daemon.py From search-MjoLniR with MIT License | 5 votes |
def task_done(self) -> None: ...
Example #9
Source File: msearch_daemon.py From search-MjoLniR with MIT License | 5 votes |
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()
Example #10
Source File: threaded_save.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()
Example #11
Source File: oldtest.py From keylime with BSD 2-Clause "Simplified" License | 5 votes |
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()
Example #12
Source File: interfacelift-downloader.py From interfacelift-downloader with MIT License | 5 votes |
def download_worker(): while True: url = queue.get() download_file(url, SAVE_DIR) queue.task_done() # Returns the path of the specified page number
Example #13
Source File: orm.py From pyscp with MIT License | 5 votes |
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()