Search code examples
pythoninter-process-communicat

Communication between two python scripts


a methodology question:

I have a "main" python script which runs on an infinite loop on my system, and I want to send information to it (a json data string for example) occasionally with some other python scripts that will be started later by myself or another program and will end just after sending the string.

I can't use subprocess here because my main script doesn't know when the other will run and what code they will execute.

I'm thinking of making the main script listen on a local port and making the other scripts send it the strings on that port, but is there a better way to do it ?


Solution

  • zeromq: http://www.zeromq.org/ - is best solution for interprocess communications imho and have a excelent binding for python: http://www.zeromq.org/bindings:python