Skip to content

Commit

Permalink
scheduler patch, thanks Niphlod
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimo committed Feb 21, 2013
1 parent 58c32f5 commit 9c97063
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Version 2.4.1-alpha.2+timestamp.2013.02.21.09.57.59
Version 2.4.1-alpha.2+timestamp.2013.02.21.10.15.58
17 changes: 11 additions & 6 deletions gluon/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def demo2():

from gluon import DAL, Field, IS_NOT_EMPTY, IS_IN_SET, IS_NOT_IN_DB, IS_INT_IN_RANGE, IS_DATETIME
from gluon.utils import web2py_uuid
from gluon.storage import Storage


QUEUED = 'QUEUED'
Expand Down Expand Up @@ -203,6 +204,7 @@ def flush(self):
def write(self, data):
self.out_queue.put(data)

W2P_TASK = Storage({'id' : task.task_id, 'uuid' : task.uuid})
stdout = LogOutput(out)
try:
if task.app:
Expand All @@ -226,6 +228,8 @@ def write(self, data):
if not isinstance(_function, CALLABLETYPES):
raise NameError(
"name '%s' not found in scheduler's environment" % f)
#Inject W2P_TASK into environment
_env.update({'W2P_TASK' : W2P_TASK})
globals().update(_env)
args = loads(task.args)
vars = loads(task.vars, object_hook=_decode_dict)
Expand Down Expand Up @@ -504,7 +508,7 @@ def define_tables(self, db, migrate):

db.define_table(
'scheduler_run',
Field('scheduler_task', 'reference scheduler_task'),
Field('task_id', 'reference scheduler_task'),
Field('status', requires=IS_IN_SET(RUN_STATUS)),
Field('start_time', 'datetime'),
Field('stop_time', 'datetime'),
Expand All @@ -521,7 +525,7 @@ def define_tables(self, db, migrate):
Field('last_heartbeat', 'datetime'),
Field('status', requires=IS_IN_SET(WORKER_STATUS)),
Field('is_ticker', 'boolean', default=False, writable=False),
Field('group_names', 'list:string', default=self.group_names),
Field('group_names', 'list:string', default=self.group_names),#FIXME writable=False or give the chance to update dinamically the groups?
migrate=migrate)
if migrate:
db.commit()
Expand Down Expand Up @@ -626,7 +630,7 @@ def pop_task(self, db):
logger.debug(' new scheduler_run record')
try:
run_id = db.scheduler_run.insert(
scheduler_task=task.id,
task_id=task.id,
status=RUNNING,
start_time=now,
worker_name=self.worker_name)
Expand All @@ -650,7 +654,8 @@ def pop_task(self, db):
stop_time=task.stop_time,
retry_failed=task.retry_failed,
times_failed=task.times_failed,
sync_output=task.sync_output)
sync_output=task.sync_output,
uuid=task.uuid)

def report_task(self, task, task_report):
db = self.db
Expand Down Expand Up @@ -983,12 +988,12 @@ def task_status(self, ref, output=False):
else:
raise SyntaxError(
"You can retrieve results only by id, uuid or Query")
fields = st.ALL
fields = [st.ALL]
left = False
orderby = ~st.id
if output:
fields = st.ALL, sr.ALL
left = sr.on(sr.scheduler_task == st.id)
left = sr.on(sr.task_id == st.id)
orderby = ~st.id | ~sr.id
row = self.db(q).select(
*fields,
Expand Down
10 changes: 5 additions & 5 deletions scripts/writedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ def main(path):
print '<h1>Models</h1>'
for filename in models:
print '<h2>%s</h2>' % filename[len(path):]
print CODE(open(filename).read(),lanuage='web2py').xml()
print CODE(open(filename).read(),language='web2py').xml()
print '<h1>Layout Views</h1>'
for filename in views:
print '<h2>%s</h2>' % filename[len(path):]
print CODE(open(filename).read(),lanuage='html').xml()
print CODE(open(filename).read(),language='html').xml()
print '<h1>Controllers and Views</h1>'
for filename in controllers:
print '<h2>%s</h2>' % filename[len(path):]
print CODE(open(filename).read(),lanuage='web2py')
print CODE(open(filename).read(),language='web2py')
views = glob.glob(os.path.join(path,'views','*','*.html'))
views.sort()
for filename in views:
print '<h2>%s</h2>' % filename[len(path):]
print CODE(open(filename).read(),lanuage='html').xml()
print CODE(open(filename).read(),language='html').xml()
print '<h1>Modules</h1>'
for filename in modules:
print '<h2>%s</h2>' % filename[len(path):]
print CODE(open(filename).read(),lanuage='python').xml()
print CODE(open(filename).read(),language='python').xml()
print '</body></html>'

if __name__=='__main__':
Expand Down

0 comments on commit 9c97063

Please sign in to comment.