Marbaloo Schedule 0.1.0 | GitLocker.com Product

marbaloo_schedule 0.1.0

Last updated:

0 purchases

marbaloo_schedule 0.1.0 Image
marbaloo_schedule 0.1.0 Images

Free

Languages

Categories

Add to Cart

Description:

marbaloo schedule 0.1.0

Schedule support for cherrypy.

Installation
pip install marbaloo_schedule


Usage
# app.py
import cherrypy
import marbaloo_schedule

schedule_plugin = marbaloo_schedule.Plugin(cherrypy.engine)
schedule_plugin.subscribe()
cherrypy.tools.schedule = marbaloo_schedule.Tool()


class Root(object):
job_started = False

def do_jobs(self):
import schedule
# request level jobs
# e.g: send emails
# if my_job_completed:
# schedule.CancelJob
pass

@cherrypy.expose
def index(self):
schedule = cherrypy.request.schedule
if self.job_started is False:
schedule.every(5).seconds.do(self.do_jobs)
return 'jobs started :)'
else:
return 'jobs already started!'

config = {
'/': {
'tools.schedule.on': True
}
}
cherrypy.quickstart(Root(), '/', config)
And for server level jobs something like this:
import cherrypy
import marbaloo_schedule

schedule_plugin = marbaloo_schedule.Plugin(cherrypy.engine)
schedule_plugin.subscribe()


class Root:
pass

cherrypy.tree.mount(Root(), '/', {})
cherrypy.engine.signals.subscribe()
cherrypy.engine.start()


def do_server_jobs():
# server level jobs
print('Job is Done')
schedule_plugin.schedule.every(5).seconds.do(do_server_jobs)

cherrypy.engine.block()
P.S: For stop jobs anywhere, use schedule tags.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.