better logic for passing parameters to scheduler, thanks Paolo
This commit is contained in:
1 parent
8c29f8b12a
commit
563de284f7
3 files changed
+31
-46
No files matched your search
+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 = TicketStorage(db=request.tickets_db)
|
||||||
ticket_storage.store(request, request.uuid.split('/', 1)[1], d)
|
ticket_storage.store(request, request.uuid.split('/', 1)[1], d)
|
||||||
cmd_opts = global_settings.cmd_options
|
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)
|
logger.error(self.traceback)
|
||||||
return request.uuid
|
return request.uuid
|
||||||
except:
|
except:
|
||||||
|
|||||||
+29
-44
@@ -316,8 +316,8 @@ class web2pyDialog(object):
|
|||||||
# the widget takes care of starting the scheduler
|
# the widget takes care of starting the scheduler
|
||||||
if self.options.scheduler and self.options.with_scheduler:
|
if self.options.scheduler and self.options.with_scheduler:
|
||||||
apps = [app.strip() for app
|
apps = [app.strip() for app
|
||||||
in self.options.scheduler.split(',')
|
in self.options.scheduler.split(',').split(':', 1)[0]
|
||||||
if app in available_apps]
|
if app.strip() in available_apps]
|
||||||
for app in apps:
|
for app in apps:
|
||||||
self.try_start_scheduler(app)
|
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',
|
action='store_true',
|
||||||
help='disable all output')
|
help='disable all output')
|
||||||
|
|
||||||
parser.add_option('-e', '--errors_to_console', dest='print_errors',
|
parser.add_option('-e', '--errors_to_console',
|
||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help='log all errors to console')
|
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,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help=\
|
help=\
|
||||||
'adds coverage reporting (should be used with --run_system_tests), ' \
|
'collect coverage data when used with --run_system_tests; ' \
|
||||||
'needs Python 2.7+ and the coverage module installed. ' \
|
'require 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)')
|
|
||||||
|
|
||||||
if '-A' in sys.argv:
|
if '-A' in sys.argv:
|
||||||
k = sys.argv.index('-A')
|
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
|
interface[1] = int(interface[1]) # numeric port
|
||||||
options.interfaces.append(tuple(interface))
|
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:
|
if options.numthreads is not None and options.minthreads is None:
|
||||||
options.minthreads = options.numthreads # legacy
|
options.minthreads = options.numthreads # legacy
|
||||||
|
|
||||||
@@ -916,18 +902,17 @@ def check_existent_app(options, appname):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def get_code_for_scheduler(app, options):
|
def get_code_for_scheduler(app_groups, options):
|
||||||
if len(app) == 1 or app[1] is None:
|
app = app_groups[0]
|
||||||
code = "from gluon.globals import current;current._scheduler.loop()"
|
if not check_existent_app(options, app):
|
||||||
else:
|
print("Application '%s' doesn't exist, skipping" % app)
|
||||||
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_)
|
|
||||||
return None, None
|
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):
|
def start_schedulers(options):
|
||||||
@@ -936,17 +921,16 @@ def start_schedulers(options):
|
|||||||
except:
|
except:
|
||||||
sys.stderr.write('Sorry, -K only supported for Python 2.6+\n')
|
sys.stderr.write('Sorry, -K only supported for Python 2.6+\n')
|
||||||
return
|
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)
|
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:
|
if len(apps) == 1 and not options.with_scheduler:
|
||||||
app_, code = get_code_for_scheduler(apps[0], options)
|
app, code = get_code_for_scheduler(apps[0], options)
|
||||||
if not app_:
|
if not app:
|
||||||
return
|
return
|
||||||
print('starting single-scheduler for "%s"...' % app_)
|
print('starting single-scheduler for "%s"...' % app)
|
||||||
run(app_, True, True, None, False, code)
|
run(app, True, True, None, False, code)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Work around OS X problem: http://bugs.python.org/issue9405
|
# Work around OS X problem: http://bugs.python.org/issue9405
|
||||||
@@ -956,12 +940,13 @@ def start_schedulers(options):
|
|||||||
import urllib.request as urllib
|
import urllib.request as urllib
|
||||||
urllib.getproxies()
|
urllib.getproxies()
|
||||||
|
|
||||||
for app in apps:
|
processes = []
|
||||||
app_, code = get_code_for_scheduler(app, options)
|
for app_groups in apps:
|
||||||
if not app_:
|
app, code = get_code_for_scheduler(app_groups, options)
|
||||||
|
if not app:
|
||||||
continue
|
continue
|
||||||
print('starting scheduler for "%s"...' % app_)
|
print('starting scheduler for "%s"...' % app)
|
||||||
args = (app_, True, True, None, False, code)
|
args = (app, True, True, None, False, code)
|
||||||
p = Process(target=run, args=args)
|
p = Process(target=run, args=args)
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
print("Currently running %s scheduler processes" % (len(processes)))
|
print("Currently running %s scheduler processes" % (len(processes)))
|
||||||
@@ -1060,7 +1045,7 @@ def start(cron=True):
|
|||||||
if options.scheduler:
|
if options.scheduler:
|
||||||
# run cron for applications listed with --scheduler (-K)
|
# run cron for applications listed with --scheduler (-K)
|
||||||
apps = [app.strip() for app in options.scheduler.split(
|
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:
|
else:
|
||||||
apps = None
|
apps = None
|
||||||
extcron = newcron.extcron(options.folder, apps=apps)
|
extcron = newcron.extcron(options.folder, apps=apps)
|
||||||
|
|||||||
Reference in new issue
Block a user