better logic for passing parameters to scheduler, thanks Paolo
This commit is contained in:
+1
-1
Submodule gluon/packages/dal updated: 37784cb6aa...f3401dd8c0
+1
-1
@@ -167,7 +167,7 @@ class RestrictedError(Exception):
|
||||
ticket_storage = TicketStorage(db=request.tickets_db)
|
||||
ticket_storage.store(request, request.uuid.split('/', 1)[1], d)
|
||||
cmd_opts = global_settings.cmd_options
|
||||
if cmd_opts and cmd_opts.print_errors:
|
||||
if cmd_opts and cmd_opts.errors_to_console:
|
||||
logger.error(self.traceback)
|
||||
return request.uuid
|
||||
except:
|
||||
|
||||
+29
-44
@@ -316,8 +316,8 @@ class web2pyDialog(object):
|
||||
# the widget takes care of starting the scheduler
|
||||
if self.options.scheduler and self.options.with_scheduler:
|
||||
apps = [app.strip() for app
|
||||
in self.options.scheduler.split(',')
|
||||
if app in available_apps]
|
||||
in self.options.scheduler.split(',').split(':', 1)[0]
|
||||
if app.strip() in available_apps]
|
||||
for app in apps:
|
||||
self.try_start_scheduler(app)
|
||||
|
||||
@@ -687,7 +687,7 @@ web2py will attempt to run a GUI to ask for it when starting the web server
|
||||
action='store_true',
|
||||
help='disable all output')
|
||||
|
||||
parser.add_option('-e', '--errors_to_console', dest='print_errors',
|
||||
parser.add_option('-e', '--errors_to_console',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='log all errors to console')
|
||||
@@ -826,11 +826,8 @@ web2py will attempt to run a GUI to ask for it when starting the web server
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=\
|
||||
'adds coverage reporting (should be used with --run_system_tests), ' \
|
||||
'needs Python 2.7+ and the coverage module installed. ' \
|
||||
'You can alter the default path setting the environment ' \
|
||||
'variable "COVERAGE_PROCESS_START" ' \
|
||||
'(by default it takes gluon/tests/coverage.ini)')
|
||||
'collect coverage data when used with --run_system_tests; ' \
|
||||
'require Python 2.7+ and the coverage module installed')
|
||||
|
||||
if '-A' in sys.argv:
|
||||
k = sys.argv.index('-A')
|
||||
@@ -890,17 +887,6 @@ web2py will attempt to run a GUI to ask for it when starting the web server
|
||||
interface[1] = int(interface[1]) # numeric port
|
||||
options.interfaces.append(tuple(interface))
|
||||
|
||||
# strip group infos from options.scheduler, in the form
|
||||
# "app:group1:group2,app2:group1", and put into a list of lists
|
||||
# in options.scheduler_groups
|
||||
if options.scheduler and ':' in options.scheduler:
|
||||
sg = options.scheduler_groups = []
|
||||
for awg in options.scheduler.split(','):
|
||||
sg.append(awg.split(':'))
|
||||
options.scheduler = ','.join([app[0] for app in sg])
|
||||
else:
|
||||
options.scheduler_groups = None
|
||||
|
||||
if options.numthreads is not None and options.minthreads is None:
|
||||
options.minthreads = options.numthreads # legacy
|
||||
|
||||
@@ -916,18 +902,17 @@ def check_existent_app(options, appname):
|
||||
return True
|
||||
|
||||
|
||||
def get_code_for_scheduler(app, options):
|
||||
if len(app) == 1 or app[1] is None:
|
||||
code = "from gluon.globals import current;current._scheduler.loop()"
|
||||
else:
|
||||
code = "from gluon.globals import current;current._scheduler.group_names = ['%s'];"
|
||||
code += "current._scheduler.loop()"
|
||||
code = code % ("','".join(app[1:]))
|
||||
app_ = app[0]
|
||||
if not check_existent_app(options, app_):
|
||||
print("Application '%s' doesn't exist, skipping" % app_)
|
||||
def get_code_for_scheduler(app_groups, options):
|
||||
app = app_groups[0]
|
||||
if not check_existent_app(options, app):
|
||||
print("Application '%s' doesn't exist, skipping" % app)
|
||||
return None, None
|
||||
return app_, code
|
||||
code = 'from gluon.globals import current;'
|
||||
if len(app_groups) > 1:
|
||||
code += "current._scheduler.group_names=['%s'];" % "','".join(
|
||||
app_groups[1:])
|
||||
code += "current._scheduler.loop()"
|
||||
return app, code
|
||||
|
||||
|
||||
def start_schedulers(options):
|
||||
@@ -936,17 +921,16 @@ def start_schedulers(options):
|
||||
except:
|
||||
sys.stderr.write('Sorry, -K only supported for Python 2.6+\n')
|
||||
return
|
||||
processes = []
|
||||
apps = options.scheduler_groups or \
|
||||
[(app.strip(), None) for app in options.scheduler.split(',')]
|
||||
code = "from gluon.globals import current;current._scheduler.loop()"
|
||||
logging.getLogger().setLevel(options.debuglevel)
|
||||
|
||||
apps = [[n.strip() for n in sched_app.split(':')]
|
||||
for sched_app in options.scheduler.split(',')]
|
||||
if len(apps) == 1 and not options.with_scheduler:
|
||||
app_, code = get_code_for_scheduler(apps[0], options)
|
||||
if not app_:
|
||||
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)
|
||||
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
|
||||
@@ -956,12 +940,13 @@ def start_schedulers(options):
|
||||
import urllib.request as urllib
|
||||
urllib.getproxies()
|
||||
|
||||
for app in apps:
|
||||
app_, code = get_code_for_scheduler(app, options)
|
||||
if not app_:
|
||||
processes = []
|
||||
for app_groups in apps:
|
||||
app, code = get_code_for_scheduler(app_groups, options)
|
||||
if not app:
|
||||
continue
|
||||
print('starting scheduler for "%s"...' % app_)
|
||||
args = (app_, True, True, None, False, code)
|
||||
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)))
|
||||
@@ -1060,7 +1045,7 @@ def start(cron=True):
|
||||
if options.scheduler:
|
||||
# run cron for applications listed with --scheduler (-K)
|
||||
apps = [app.strip() for app in options.scheduler.split(
|
||||
',') if check_existent_app(options, app.strip())]
|
||||
',').split(':', 1)[0] if check_existent_app(options, app.strip())]
|
||||
else:
|
||||
apps = None
|
||||
extcron = newcron.extcron(options.folder, apps=apps)
|
||||
|
||||
Reference in New Issue
Block a user