<s> import optparse <EOL> import os <EOL> import sys <EOL> import logging <EOL> from rq import Worker <EOL> from rq import Queue <EOL> from rq import Connection <EOL> from rq . job import JobStatus <EOL> from totalimpactwebapp import redis_rq_conn <EOL> from totalimpactwebapp import ti_queues <EOL> import argparse <EOL> def failed_job_handler ( job , exc_type , exc_value , traceback ) : <EOL> print "<STR_LIT>" . format ( <EOL> job . meta , exc_type , exc_value , traceback <EOL> ) <EOL> return True <EOL> def start_worker ( queue_name ) : <EOL> print "<STR_LIT>" . format ( queue_name ) <EOL> with Connection ( redis_rq_conn ) : <EOL> worker = Worker ( Queue ( queue_name ) , exc_handler = failed_job_handler ) <EOL> worker . work ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , type = int , help = "<STR_LIT>" ) <EOL> args = vars ( parser . parse_args ( ) ) <EOL> queue_name = "<STR_LIT>" . format ( args [ "<STR_LIT>" ] ) <EOL> print u"<STR_LIT>" . format ( <EOL> queue_name = queue_name <EOL> ) <EOL> start_worker ( queue_name ) </s>
