#NEWLINE# def test_stopCooperatorReentrancy( self ) : #NEWLINE# #INDENT# "\n        If a callback of a L{Deferred} from L{CooperativeTask.whenDone} calls\n        C{Cooperator.stop} on its L{CooperativeTask._cooperator}, the\n        L{Cooperator} will stop, but the L{CooperativeTask} whose callback is\n        calling C{stop} should already be considered 'stopped' by the time the\n        callback is running, and therefore removed from the\n        L{CoooperativeTask}.\n        " #NEWLINE# callbackPhases = [ ] #NEWLINE# def stopit( result ) : #NEWLINE# #INDENT# callbackPhases . append ( result ) #NEWLINE# self . cooperator . stop ( ) #NEWLINE# callbackPhases . append ( 'done' ) #NEWLINE# #UNINDENT# self . task . whenDone ( ) . addCallback ( self ) #NEWLINE# self . stopNext ( ) #NEWLINE# self . scheduler . pump ( ) #NEWLINE# self . assertEqual ( callbackPhases , [ self . task . _iterator , 'done' ] )