Nextdoor / ndscheduler

A flexible python library for building your own cron-like system, with REST APIs and a Web UI.
BSD 2-Clause "Simplified" License
1.09k stars 201 forks source link

Implimentation #45

Closed SimplySynced closed 5 years ago

SimplySynced commented 5 years ago

Hello, I'm building an aquarium controller that is open sourced and was looking to build a scheduler into it. It is a flask app and I was wondering if you have an example of this being used in a flask app. Does this need to run separate from the app and then the app can use the API to communicate with it back and forth? Appreciate it.

sabw8217 commented 5 years ago

I'm not sure how using this with Flask would work, this is a Tornado app. I don't know much about Flask but I'm pretty sure it is a blocking framework, not one that can be run in an Tornado event loop. If you can figure out how to run Flask inside Tornado you could try overriding some of the server code in https://github.com/Nextdoor/ndscheduler/blob/master/ndscheduler/server/server.py (or mapping the URLs in your own Tornado server).

You could also run it as a separate server and use the API.

If you want something that can be used as a scheduler but could be run from inside a Flask app, you might want to look at APScheduler which is what ndscheduler is built on.