def run():
    sys.path.insert(0, '')
    parser = _get_argparser()
    parser.description = 'Run a tasa worker.'
    parser.add_argument('worker',
                        type=lambda w: w.partition(':')[::2],
                        help='Worker module. In the form: '
                        '"path.to.my.module:MyWorkerClass". Relative to '
                        'the current directory.')
    args = parser.parse_args()

    worker_class_name = args.worker[1] or 'Worker'
    worker_module = __import__(args.worker[0], globals(), locals(),
                               [worker_class_name])
    try:
        WorkerClass = getattr(worker_module, worker_class_name)
    except AttributeError:
        print "No matching workers found.\n"
        potential_workers = inspect.getmembers(
            worker_module,
            lambda x: type(x) == type and issubclass(x, BaseWorker))
        if potential_workers:
            print "Found potential workers:"
            for name, value in potential_workers:
                print ':'.join([args.worker[0], name])
        exit(1)
    worker = WorkerClass()
    print 'Running worker: %s:%s' % (args.worker[0],
                                     worker.__class__.__name__)
    try:
        for job in worker:
            if job:
                logger.info("Doing job: %s:%s",
                            worker.__class__.__name__,
                            str(job)[:50])
            else:
                # FIXME: do something better here
                time.sleep(.3)
    except __HOLE__:
        print 'Exiting worker.'
dataset/ETHPy150Open PaulMcMillan/tasa/tasa/cli.py/run