<s> import sys , time , os <EOL> def noop ( * args ) : <EOL> pass <EOL> def setup ( * specs ) : <EOL> if os . environ . get ( '<STR_LIT>' ) and os . environ [ '<STR_LIT>' ] . lower ( ) in [ '<STR_LIT:1>' , '<STR_LIT:yes>' , '<STR_LIT:true>' ] : <EOL> return ( noop , noop ) <EOL> else : <EOL> return perform_setup ( * specs ) <EOL> def perform_setup ( * specs ) : <EOL> from . import runwsgi <EOL> app_specs = [ ] <EOL> for spec in specs : <EOL> app_module = __import__ ( spec [ <NUM_LIT:0> ] , globals ( ) , locals ( ) , [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> app = getattr ( app_module , '<STR_LIT>' ) <EOL> app_specs . append ( [ app ] + list ( spec [ <NUM_LIT:1> : ] ) ) <EOL> return runwsgi . app_runner_setup ( * app_specs ) <EOL> quit = False <EOL> def sigterm_handler ( * args ) : <EOL> global quit <EOL> quit = True <EOL> def run_standalone ( ) : <EOL> import signal <EOL> funcs = [ ] <EOL> signal . signal ( signal . SIGTERM , sigterm_handler ) <EOL> funcs . append ( setup ( ( '<STR_LIT>' , <NUM_LIT> ) ) ) <EOL> funcs . append ( setup ( ( '<STR_LIT>' , <NUM_LIT> ) ) ) <EOL> funcs . append ( setup ( ( '<STR_LIT>' , <NUM_LIT> ) ) ) <EOL> funcs . append ( setup ( ( '<STR_LIT>' , <NUM_LIT> , dict ( ssl = True ) ) ) ) <EOL> for setup_func , teardown_func in funcs : <EOL> setup_func ( sys . modules [ __name__ ] ) <EOL> sys . stdout . write ( "<STR_LIT>" ) <EOL> try : <EOL> while not quit : <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> except KeyboardInterrupt : <EOL> pass <EOL> for setup_func , teardown_func in funcs : <EOL> teardown_func ( sys . modules [ __name__ ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> run_standalone ( ) </s>
