Reputation: 2589
I wrote a daemon script in python that takes dicts from a queue and processes files based on the information from those dicts. Now I want to insert some additional dicts in that queue from a separated Django script. Is it possible to expose the queue as file to other software ? If not, is there any other solution ?
My project runs on debian linux.
Upvotes: 0
Views: 132
Reputation: 5442
I'm not a big fan of ipc when it comes down to rather trivial communication setups. Building a network based client server model also adds a lot of overhead. Since most probably the two processes will be running on the same machine.
You could create a file based queue, either pickle it or use some kind of serialization format. The client your seperate django script will fill that file. Your deamin will watch the file, and append the deserialized or depickled queue objects to the deamon's queue object.
pynotify for watching the file if you're running a gnu/linux os.
Upvotes: 0
Reputation: 1842
If you start the daemon from the django script, then you just need to use the object's methods (or directly access its queue) from the django script.
If the daemon is already started, then you need inter-process communication. Sockets or pipes are some options. Regularly checking a file's content is another solution, but not as responsive.
You might take a look at the official documentation.
Upvotes: 2