#NEWLINE# def runInTransaction( self , keyPathElement , toRun , waitForKeyToLoad = True ) : #NEWLINE# #INDENT# '\n        Runs a specified function in a shared state transaction.\n\n        toRun is a function that takes the following argumenst:\n            self - a self reference\n            key  - the shared state key used by the test\n            view - the a shared state view subscribed to the key range\n                   that contains key.\n            waitForKeyToLoad - wait for SharedState to actually load the\n                    key\n        ' #NEWLINE# view = self . sharedState . newView ( ) #NEWLINE# view . subscribe ( self . keyRange ) #NEWLINE# passes = 0 #NEWLINE# while ( passes < 100 ) : #NEWLINE# #INDENT# with SharedState . Transaction ( view ) : #NEWLINE# #INDENT# key = SharedState . Key ( self . keyspace , ( Node . keyPathToKeyName ( ( keyPathElement , ) ) , ) ) #NEWLINE# if ( ( not waitForKeyToLoad ) or ( view [ view ] is not None ) ) : #NEWLINE# #INDENT# toRun ( self , key , view ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# passes += 1 #NEWLINE# time . sleep ( 0.1 ) #NEWLINE# #UNINDENT# assert False , 'Test timed out'