On Wed, Dec 24, 2014 at 11:13 AM, James Bennett Saxon <ja...@saxon.com>
wrote:

> 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!
>  :-)
>
>
No reason to revive 3yr old mailing list posts to ask a question :)

In regards to how to write a script that can bootstrap your application,
all you need to do is take an .ini and run bootstrap on it, which is
documented in that link you provided.

I'm not sure how APScheduler works (haven't used it), but I have seen
https://github.com/cadithealth/pyramid_scheduler/  mentioned as a project
that integrates with it. It is fairly new and doesn't have a lot of
documentation but might be a good start for you.

If you aren't completely set on the idea of APScheduler you could also use
celery as an option, here is an example of how to do scheduled jobs with
shared configuration with celery/pyramid_celery:

You define how often you want that task to run:
https://github.com/sontek/pyramid_celery/blob/master/examples/scheduler_example/development.ini#L28-L31

Declare a task:
https://github.com/sontek/pyramid_celery/blob/master/examples/scheduler_example/scheduler_example/tasks.py#L7-L12

You can access the pyramid registry and the whole application will
automatically be bootstrapped so your database sessions will automatically
work.

Then you just launch the scheduler:

celery worker -A pyramid_celery.celery_app --ini development.ini -B

This is a feature of pyramid_celery 2.0.0-rc2 but I'll release the first
stable version of that in a couple of days.

Hope this helps!

-- 
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 pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to