Reputation:
I am looking for a way to run a python program that listens to calls from other another python program. I tried it through the HTTP protocol, but it's very slow when heavily used. Is it possible to listen to memory entries that another python program writes? Or another solution? Sending and retrieving calls happens on the same machine.
Like I set up a while loop that never ends and every time looks into a file and reads it.
I guess database software like Google's LevelDB and MongoDB use the same method.
Edit: There can be several calls at once and the script is running all the time.
Upvotes: 0
Views: 244
Reputation: 1704
Try the most excellent Pyro which gives you remote object calling in python:
http://irmen.home.xs4all.nl/pyro/
Go straight to the simple example, which includes a server (greeting.py) which hangs around waiting for a client (client.py) to send it a message:
http://packages.python.org/Pyro4/intro.html#simple-example
Upvotes: 0
Reputation: 6955
Are "the calls" going to be issued from the same machine?
Named pipes may be an option http://mail.python.org/pipermail/python-list/2005-March/312152.html
UPD: sockets mentioned in other answer look like more appropriate way to accomplish it
Upvotes: 0
Reputation: 19963
This is a super-vague question, but if you need two processes to talk to one another, maybe you can use sockets? You can send pickled objects through sockets or any other communication method you care to name, if that helps.
Upvotes: 1