November 8, 2016 · ucsmsdk ucspython

Multiple parallel transactions - ucsmsdk 0.9.1.1

Until ucsmsdk 0.9.1.0 everything until a handle.commit was a single transaction,

handle.add_mo(mo1)  
handle.add_mo(mo2)  
handle.remove_mo(mo3)  
handle.commit()  

Starting 0.9.1.1 there is an optional tag parameter added to add_mo,set_mo,remove_mo,commit. tag is the scope of a transaction.

So, here is how two parallel transactions can be done.

handle.add_mo(mo1, tag="trans_1")  
handle.add_mo(mo2, tag="trans_2")  
handle.add_mo(mo3, tag="trans_1")  
handle.remove_mo(mo4, tag="trans_2")

# Commit transaction #2
handle.commit(tag="trans_2")

handle.add_mo(mo5, tag="trans_1")

# Commit transaction #1
handle.commit(tag="trans_1")  

use case: if we wanted to use the same handle object in different threads, the thread.name could be passed as the tag parameter. This would ensure that operations in one thread do not affect others.

Without the tag parameter the behaviour is as it was in 0.9.1.0

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket