Twisted and python list concurrent access -


I have twists in the python with current access to the list. I have a twisted class that adds data to a list , And a method called every 4 seconds, this method is the element of the list and performs some operations. I am afraid that both of the same list can cause stability problems both from the dew periodic and both of the data obtained. Here's the code:

  ossStorage = [] def ossPeriodic (): I in Ostorage: ossStorage.remove (i) db.insertDataToDb (i) reactor. Thalator (4, Osperodic) Class OSS (Protocol): Received DIF Data (Self, Data): Account = Pickle. Loads (data) ossStorage.append (account) DEIF Main (): ossFactory = Factory () ossFactory.protocol = OSS ReactorListen TCP (50000, OSSFFT) Reactor Collator (4, Osperodic) Reactor.Ran ()   

Should I use lock or something similar? Thanks!

Are you using thread? If not, you do not have concurrent access to the list.

Generally using an application thread does not use twisted. Asynchronous nature of Twist executes every event in an event. Asynchronous nature provides for concurrent kind of behavior, such as handling multiple network connections parallel, but each callback function runs until the next one completes.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -