'Test reactor shutdown while in a recvfrom() loop'

def testShutdownFromDatagramReceived(self):

    finished = defer.Deferred()
    pr = self.server.packetReceived = defer.Deferred()
    def pktRece(ignored):
        self.server.transport.connectionLost()
        reactor.callLater(0, finished.callback, None)
    pr.addCallback(pktRece)
    def flushErrors(ignored):
        self.flushLoggedErrors()
    finished.addCallback(flushErrors)
    self.server.transport.write(('\x00' * 64), ('127.0.0.1', self.server.transport.getHost().port))
    return finished
