#NEWLINE# def test_stopProtocolScheduling( self ) : #NEWLINE# #INDENT# '\n        L{DatagramProtocol.stopProtocol} is called asynchronously (ie, not\n        re-entrantly) when C{stopListening} is used to stop the the datagram\n        transport.\n        ' #NEWLINE# class DisconnectingProtocol ( DatagramProtocol ) : #NEWLINE# #INDENT# started = False #NEWLINE# stopped = False #NEWLINE# inStartProtocol = False #NEWLINE# stoppedInStart = False #NEWLINE# def startProtocol( self ) : #NEWLINE# #INDENT# self . started = True #NEWLINE# self . inStartProtocol = True #NEWLINE# self . transport . stopListening ( ) #NEWLINE# self . inStartProtocol = False #NEWLINE# #UNINDENT# def stopProtocol( self ) : #NEWLINE# #INDENT# self . stopped = True #NEWLINE# self . stoppedInStart = self . inStartProtocol #NEWLINE# reactor . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# reactor = self . buildReactor ( ) #NEWLINE# protocol = DisconnectingProtocol ( ) #NEWLINE# self . getListeningPort ( reactor , protocol ) #NEWLINE# self . runReactor ( reactor ) #NEWLINE# self . assertTrue ( protocol . started ) #NEWLINE# self . assertTrue ( protocol . stopped ) #NEWLINE# self . assertFalse ( protocol . stoppedInStart )