Is there a data structure in a Python like a blocking dictionary?
- It should be randomly accessible and any element should be modified / deleted (only first or last
- One should be blocked () and put ()
- this thread should be secure
I would have used a queue, but Blocking and securing the thread, however, it is not randomly accessible a single dot is not blocked either (as far as Era Python's knowledge). As an example, a manufacturer add key-value Yugj such data-structure thread update the values of (existing key that already exists - will not cut it in a queue is where), and Blocking a worker () and these key-value pairs become available as they become available. Thanks a lot!
EDIT: Let's consider the manufacturer's choices on a CI server and get project-status added. This project creates a difference in situations and puts them in the figure structure beforehand. Worker picks up updated in project status and as an animation on the screen one by showing them a
class manufacturer :. Def generateProjectStatusChanges (): ... updateSuperAwesomeDataStructure (change) def: for (proj, changes in state): #queue will not work due to update dict behavior can take place between superAwesomeDS.putOrUpdate #hence line (proj, State ) watchForUpdates () def: changes = generateProjectStatusChanges () updateSuperAwesomeDataStructure (change) time.sleep (self.interval) class worker: def blockingNotifyAnimation (): ... def watchForUpdates (): while true: proj, State = superAwesomeDS.getFirstPair ( ) #or In fact any pair blockingNotifyAnimation (proj, state)
Should some move (untested) with the following lines:
class UpdatableBlockingQueue (object): def __init __ (self) : Self.queue = {} self.cv = threading.Condition () put def (self, key, value): with self.cv: self.queue [key] = value self.cv.notify () def (self) ): With self.cv: while self.queue not: self.cv.wait () refund self.queue.popitem ()
uses it for a line queue and a condition Siege between serializing access and threads for variables Sex.
Comments
Post a Comment