I'm liking the way I can dynamically schedule APScheduler. I'm getting tripped up on the pyramid/models/views integration.
Let's suppose I wanted to have all the code together in this single app so I can share models with the scheduling daemon AND the pyramid app. What's the baseline method for running a python script which bootstraps models and pyramid so I can keep as DRY as possible. I see how in the ini files I can add a [pshell] section to pull in models and sessions. http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/narr/commandline.html#writing-a-script Is there a place where I can get a full daemon script example? There are too many words, I'm not making these high level connections. Too abstract! :-) On Monday, June 18, 2012 7:07:39 AM UTC-7, Daniel Holth wrote: > > APScheduler is great. I like my applications to be self-contained and > system independent. So, personally I avoid cron jobs. For a simple > single-process webapp it's fine to start out with a scheduler thread. When > your application gets more complex you could run APScheduler in a > separately managed process such as, if you are using uwsgi, a uwsgi mule. > > Your example code will probably spend most of its time waiting for I/O, > not holding the GIL. > > On Saturday, June 16, 2012 4:52:37 AM UTC-4, Stéphane Klein wrote: >> >> The way you >> >>> Writing separate script running as a >>> daemon won't impact performance of the web app itself in case if you are >>> up to some resource intensive tasks (which I assume you do). >> >> >> In this source code, do you think daemon can impact performance of the >> web app ? >> It's is a bad idea to start scheduler in my webapp ? >> >> Is there an issue with Global Internal Lock of Python ? >> >> from apscheduler.scheduler import Scheduler >> import requests >> >> sched = Scheduler() >> >> @sched.interval_schedule(seconds=10) >> def some_job(): >> print('start') >> for a in range(1, 10): >> r = requests.get('http://www.google.fr') >> print(r.status_code) >> >> print('fin') >> >> sched.configure() >> sched.start() >> >> from wsgiref.util import setup_testing_defaults >> from wsgiref.simple_server import make_server >> >> def simple_app(environ, start_response): >> setup_testing_defaults(environ) >> >> status = '200 OK' >> headers = [('Content-type', 'text/plain')] >> >> start_response(status, headers) >> >> ret = ["%s: %s\n" % (key, value) >> for key, value in environ.iteritems()] >> return ret >> >> httpd = make_server('', 8000, simple_app) >> print "Serving on port 8000..." >> httpd.serve_forever() >> >> > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
