Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
813 views
in Technique[技术] by (71.8m points)

inter 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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...