#NEWLINE# def testScanAbandonedLocks( self ) : #NEWLINE# #INDENT# 'Test scanning for locks which were abandoned due to server failure.' #NEWLINE# def _OpMethod( client , callback ) : #NEWLINE# #INDENT# self . _method_count += 1 #NEWLINE# callback ( ) #NEWLINE# if ( self . _method_count == 10 ) : #NEWLINE# #INDENT# self . io_loop . add_callback ( self . stop ) #NEWLINE# #UNINDENT# #UNINDENT# for i in xrange ( 10 ) : #NEWLINE# #INDENT# lock = self . _AcquireOpLock ( user_id = ( i / 2 ) ) #NEWLINE# lock . Abandon ( self . _client , self . stop ) #NEWLINE# self . wait ( ) #NEWLINE# self . _CreateTestOp ( user_id = ( i / 2 ) , handler = _OpMethod ) #NEWLINE# #UNINDENT# Lock . TryAcquire ( _OpMethod . _client , LockResourceType . Job , 'v0' , ( lambda lock , status : self . stop ( lock ) ) , detect_abandonment = True ) #NEWLINE# lock = self . wait ( ) #NEWLINE# lock . Abandon ( self . _client , self . stop ) #NEWLINE# self . wait ( ) #NEWLINE# op_mgr = self . _CreateOpManager ( handlers = [ _OpMethod ] ) #NEWLINE# op_mgr . _ScanAbandonedLocks ( ) #NEWLINE# self . wait ( ) #NEWLINE# self . _RunAsync ( op_mgr . Drain )