#NEWLINE# def test_immediate_cancel( self ) : #NEWLINE# #INDENT# '\n        Immediately cancelling the result of @run_in_reactor function will\n        still cancel the Deferred.\n        ' #NEWLINE# program = 'import os, threading, signal, time, sys\n\nfrom twisted.internet.defer import Deferred, CancelledError\n\nimport crochet\ncrochet.setup()\n\n@crochet.run_in_reactor\ndef run():\n    return Deferred()\n\ner = run()\ner.cancel()\ntry:\n    er.wait(1)\nexcept CancelledError:\n    sys.exit(23)\nelse:\n    sys.exit(3)\n' #NEWLINE# process = subprocess . Popen ( [ sys . executable , '-c' , program ] , cwd = crochet_directory ) #NEWLINE# self . assertEqual ( process . wait ( ) , 23 )