On thread safety in python using D-Bus asynchronous method calls -


I write a Python class which calls the asynchronous method using D-Bus. When my answer_handler is called, it stores data in the list. This list can be used for the second class methods at the same time. Is it safe or can I use synchronized data structures like queue class?

If you list out the callback reference, you do not need the necessary synchronization - you only know this The state of the inventory item is unstable

If the list should also be modified in the callback handler, as well as the main performance reference (or other threads, etc.), then yes you will need to synchronize.

Python synchronizes Q works naturally for message pumps - allowing you to sort actions in order so that events can come in any of your references. With this simplicity and readability, this profit code is easy to track major state changes. Callback should not normally be complicated in any way, because in the external context callbacks (and probably not) will have to deal with the exceptions raised by your code. At the same time there may be potential considerations - callback will block the reference of the async emitter - hence handling less handler and keeping sweets is also good.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -