ClearableQueue¶
- 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
Clear out any data from the queue |
|
Reliable implementation of multiprocessing.Queue.empty() |
|
Gets the results and tries to flush from the holder if anything is in it |
|
Reliable implementation of multiprocessing.Queue.qsize() |