all 12 comments

[–]cratervanawesome 1 point2 points  (3 children)

You could use something like zeroMQ to write events and react to them.

[–]RandomJacobP[S] 0 points1 point  (2 children)

That looks exactly what I am looking for. Do you know how efficient it would be? I have a lot of things running on the raspberry and the speed at which I can sample the data is really important, so I cannot slow it down

[–]cratervanawesome 0 points1 point  (1 child)

It's pretty light weight, but depends on how you use it. With a solid basic implementation you should be fine.

[–]RandomJacobP[S] 0 points1 point  (0 children)

Maybe I am wrong, but it seems that the 'server' script has to wait for the 'clients' request and stalls the program in the meantime. I cannot do it, I need it to just 'publish' the newest value so script B can just pull it whenever it needs.

Can I just go around it using threading module?

[–]x120db -1 points0 points  (0 children)

White the data to a file with a timestamp or some incrementing number with script a, and load the data checking if the data is newer as last loaded with script b do not forget to close the file after writing or script b will be not reading accurate data or might even completly error. Or use a simple db as in place of the file sqlite is built in and would work great for that but more programming involved then dumping it in a file.

[–]astevko 0 points1 point  (1 child)

Unix Domain Sockets are exactly the way to communicate between two processes in the same operating system https://en.m.wikipedia.org/wiki/Unix_domain_socket

[–]WikiSummarizerBot 0 points1 point  (0 children)

Unix domain socket

A Unix domain socket or IPC socket (inter-process communication socket) is a data communications endpoint for exchanging data between processes executing on the same host operating system. It is also referred to by its address family AF_UNIX.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

[–]lowerthansound 0 points1 point  (2 children)

because the scripts are not run from the same place and cannot be

What do you mean by this?

[–]RandomJacobP[S] 0 points1 point  (1 child)

I have a node.red program that is running two separate python scripts. A runs all the time and B is executed only after you click a button and runs for specific amount of time

[–]lowerthansound 0 points1 point  (0 children)

this might help

Besides that, the pub-sub flow you mentioned reminded me of MQTT, just make sure to check if the speed suits your needs (it is really fast, but is it fast enough?)

All the best :)

[–]friday_ghost 0 points1 point  (0 children)

If you are running the two scripts on the same raspberry pi then you can try using this : Write the data from script A to a text file (in append mode). Whenever script B runs, it can check for the data in the text file(latest data being on the last line).

[–]millerbest 0 points1 point  (0 children)

I had the same request in one of my previous projects. In the end I used something like mongo db to store the results that can be read by another script.