Module Expr Str ImportFrom alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias alias alias alias alias ImportFrom alias ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call AttributeLoad NameLoad attr ListLoad AttributeLoad NameLoad attr Str NameLoad keyword NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore NameLoad ClassDef bases body FunctionDef arguments args NameParam defaults body Return NameLoad decorator_list decorator_list Assign NameStore Call NameLoad Call NameLoad Lambda arguments args defaults Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr Lambda arguments args defaults Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr NameLoad Num Expr Call AttributeLoad NameLoad attr Lambda arguments args NameParam defaults Call AttributeLoad NameLoad attr NameLoad keyword Num Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad ListLoad Num Num Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr Lambda arguments args defaults Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Lambda arguments args defaults BinOpDiv Num Num Expr Call AttributeLoad NameLoad attr Lambda arguments args defaults Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad ListLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad Num decorator_list decorator_list
N/A N/A 
Tests for _shutdown.
 __future__ absolute_import N/A sys N/A subprocess N/A time twisted.trial.unittest TestCase crochet._shutdown Watchdog FunctionRegistry _watchdog register _registry tests crochet_directory ShutdownTests N/A TestCase N/A N/A 
    Tests for shutdown registration.
     test_shutdown N/A N/A self N/A N/A N/A 
        A function registered with _shutdown.register() is called when the
        main thread exits.
         N/A program import threading, sys

from crochet._shutdown import register, _watchdog
_watchdog.start()

end = False

def thread():
    while not end:
        pass
    sys.stdout.write("byebye")
    sys.stdout.flush()

def stop(x, y):
    # Move this into separate test at some point.
    assert x == 1
    assert y == 2
    global end
    end = True

threading.Thread(target=thread).start()
register(stop, 1, y=2)

sys.exit()
 N/A process N/A N/A subprocess Popen N/A N/A sys executable -c program cwd crochet_directory stdout N/A subprocess PIPE N/A result N/A N/A N/A process stdout read N/A N/A N/A self assertEqual N/A N/A process wait 0 N/A N/A N/A self assertEqual result byebye N/A test_watchdog N/A N/A self N/A N/A N/A 
        The watchdog thread exits when the thread it is watching exits, and
        calls its shutdown function.
         N/A done N/A N/A alive True FakeThread N/A N/A is_alive N/A N/A self N/A N/A N/A alive N/A N/A N/A w N/A Watchdog N/A FakeThread N/A N/A N/A N/A N/A N/A done append True N/A N/A N/A w start N/A N/A N/A time sleep 0.2 N/A N/A N/A self assertTrue N/A N/A w is_alive N/A N/A N/A self assertFalse done N/A alive False N/A N/A N/A time sleep 0.2 N/A N/A N/A self assertTrue done N/A N/A N/A self assertFalse N/A N/A w is_alive N/A test_api N/A N/A self N/A N/A N/A 
        The module exposes a shutdown thread that will call a global
        registry's run(), and a register function tied to the global registry.
         N/A N/A N/A self assertIsInstance _registry FunctionRegistry N/A N/A N/A self assertEqual register N/A _registry register N/A N/A N/A self assertIsInstance _watchdog Watchdog N/A N/A N/A self assertEqual N/A _watchdog _shutdown_function N/A _registry run N/A N/A FunctionRegistryTests N/A TestCase N/A N/A 
    Tests for FunctionRegistry.
     test_called N/A N/A self N/A N/A N/A 
        Functions registered with a FunctionRegistry are called in reverse
        order by run().
         N/A result N/A N/A registry N/A FunctionRegistry N/A N/A N/A registry register N/A N/A N/A N/A N/A N/A result append 1 N/A N/A N/A registry register N/A N/A N/A x N/A N/A N/A result append x 2 N/A N/A N/A registry register N/A N/A N/A y N/A N/A N/A result append y y 3 N/A N/A N/A registry run N/A N/A N/A self assertEqual result N/A 3 2 1 N/A test_log_errors N/A N/A self N/A N/A N/A 
        Registered functions that raise an error have the error logged, and
        run() continues processing.
         N/A result N/A N/A registry N/A FunctionRegistry N/A N/A N/A registry register N/A N/A N/A N/A N/A N/A result append 2 N/A N/A N/A registry register N/A N/A N/A N/A N/A 1 0 N/A N/A N/A registry register N/A N/A N/A N/A N/A N/A result append 1 N/A N/A N/A registry run N/A N/A N/A self assertEqual result N/A 1 2 N/A excs N/A N/A self flushLoggedErrors ZeroDivisionError N/A N/A N/A self assertEqual N/A len excs 1 N/A N/A