ClearableQueue

giant.ufo.clearable_queue:

class giant.ufo.clearable_queue.ClearableQueue(*args, **kwargs)[source]

A portable implementation of multiprocessing.Queue.

Because of multithreading / multiprocessing semantics, Queue.qsize() may raise the NotImplementedError exception on Unix platforms like Mac OS X where sem_getvalue() is not implemented. This subclass addresses this problem by using a synchronized shared counter (initialized to zero) and increasing / decreasing its value every time the put() and get() methods are called, respectively. This not only prevents NotImplementedError from being raised, but also allows us to implement a reliable version of both qsize() and empty().

Borrowed from https://github.com/keras-team/autokeras/issues/368 and https://stackoverflow.com/a/36018632/3431189

Parameters:
  • args (list) –

  • kwargs (dict) –

Summary of Methods

cancel_join_thread

clear

Clear out any data from the queue

close

empty

Reliable implementation of multiprocessing.Queue.empty()

full

get

Gets the results and tries to flush from the holder if anything is in it

get_nowait

join_thread

put

put_nowait

qsize

Reliable implementation of multiprocessing.Queue.qsize()