11from multiprocessing
import Queue
14 from queue
import Empty
16 from Queue
import Empty
21 This class is a wrapper around a multiprocessing.Queue
23 It can be used to send
and receive values
from the modules
while processing the calculation.
24 You can use it to save -
for example - filepaths of outputfiles that you create on the fly.
25 The added items are all of the type CalculationQueueItem.
26 The CalculationQueue can be used
as a dict. After the termination of the underlaying process
27 you can access the different entries by their names you gave them when putting them on the queue.
39 def put(self, name, item, **kwargs):
41 Put an item on the queue with the given name. Please keep that adding two items
with the same name
42 overrides one of them!
48 Fill the internal dict with the information of the queue.
49 Do
not call this on your own.
50 Do only call this when the underlying process has ended.
54 result = self.
queue.get_nowait()
55 self.
results.update({result.name: result.item})
61 Return the item with the given name
or an Exception when it
is not found.
62 Do
not call this on your own..
69 Return all possible names of items saved in this queue.
70 Do
not call this on your own.
73 return list(self.
results.keys())
78 A placeholder for a tuple string, object.
79 Do
not create them by yourself.
84 Create a new queue item
93 Equality operator needed for tests.
95 return other.name == self.
name and other.item == self.
item