Communicating with a running python daemon

前端 未结 8 1663
一个人的身影
一个人的身影 2020-12-07 07:45

I wrote a small Python application that runs as a daemon. It utilizes threading and queues.

I\'m looking for general approaches to altering this application so that

8条回答
  •  猫巷女王i
    2020-12-07 08:26

    Use werkzeug and make your daemon include an HTTP-based WSGI server.

    Your daemon has a collection of small WSGI apps to respond with status information.

    Your client simply uses urllib2 to make POST or GET requests to localhost:somePort. Your client and server must agree on the port number (and the URL's).

    This is very simple to implement and very scalable. Adding new commands is a trivial exercise.

    Note that your daemon does not have to respond in HTML (that's often simple, though). Our daemons respond to the WSGI-requests with JSON-encoded status objects.

提交回复
热议问题