widget.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码
def start_schedulers(options):
    try:
        from multiprocessing import Process
    except:
        sys.stderr.write('Sorry, -K only supported for python 2.6-2.7\n')
        return
    processes = []
    apps = [(app.strip(), None) for app in options.scheduler.split(',')]
    if options.scheduler_groups:
        apps = options.scheduler_groups
    code = "from gluon import current;current._scheduler.loop()"
    logging.getLogger().setLevel(options.debuglevel)
    if options.folder:
        os.chdir(options.folder)
    if len(apps) == 1 and not options.with_scheduler:
        app_, code = get_code_for_scheduler(apps[0], options)
        if not app_:
            return
        print 'starting single-scheduler for "%s"...' % app_
        run(app_, True, True, None, False, code)
        return

    # Work around OS X problem: http://bugs.python.org/issue9405
    import urllib
    urllib.getproxies()

    for app in apps:
        app_, code = get_code_for_scheduler(app, options)
        if not app_:
            continue
        print 'starting scheduler for "%s"...' % app_
        args = (app_, True, True, None, False, code)
        p = Process(target=run, args=args)
        processes.append(p)
        print "Currently running %s scheduler processes" % (len(processes))
        p.start()
        ##to avoid bashing the db at the same time
        time.sleep(0.7)
        print "Processes started"
    for p in processes:
        try:
            p.join()
        except (KeyboardInterrupt, SystemExit):
            print "Processes stopped"
        except:
            p.terminate()
            p.join()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号