views:

40

answers:

4

To give a little background, I'm writing (or am going to write) a daemon in Python for scheduling tasks to run at user-specified dates. The scheduler daemon also needs to have a JSON-based HTTP web service interface (buzzword mania, I know) for adding tasks to the queue and monitoring the scheduler's status. The interface needs to receive requests while the daemon is running, so they either need to run in a separate thread or cooperatively multitask somehow. Ideally the web service interface should run in the same process as the daemon, too.

I could think of a few ways to do it, but I'm wondering if there's some obvious module out there that's specifically tailored for this kind of thing. Any suggestions about what to use, or about the project in general are quite welcome. Thanks! :)

A: 

I'm not sure I understand your question properly, but take a look at Twisted

gnibbler
A: 

Don't invent the bicycle!

Run jobs via cron script, and create separate web interface using, for example, Django or Tornado.

Connect them via database, even sqlite will do the job if you don't want to scale on more machines.

Alexander Artemenko
+1  A: 

Check out the class BaseHTTPServer -- a "Basic HTTP server" bundled with Python. http://docs.python.org/library/basehttpserver.html

You can spin up a second thread and have it serve your requests for you very easily (probably < 30 lines of code). And it all runs in the same process and Python interpreter space, so it can access all your objects, etc.

dkamins
This is most in line with what I'm looking for. :) I think I'm going to end up going with an RPC module like python-json-rpc (http://json-rpc.org/wiki/python-json-rpc) just because it'll be easier to get it running.
Faisal
A: 

I believed all kinds of python web framework is useful.

You can pick up one like CherryPy, which is small enough to integrate into your system. Also CherryPy includes a pure python WSGI server for production.

Also the performance may not be as good as apache, but it's already very stable.

kernel1983