0

Very new to python and named pipes!

I am trying to run an GUI and a motion tracking application at the same time - and send the motion tracking application output (CSV) to the GUI script to synchronise the two data streams. Using a named pipe, how do we create a connection to sync the two applications?

I have a fully functional script for the GUI and a fully functional script for the motion tracking and cannot figure out how to add a named pipe in the GUI script to obtain the motion tracking script.

AMeng
  • 35
  • 3
  • Named pipes are unidirectional; you want a socket. – chepner Mar 08 '22 at 14:11
  • Will I need a bidirectional connection to feed the motion tracking output to the GUI ? – AMeng Mar 08 '22 at 14:21
  • When I saw "synchronization", I assumed a two-way process where each component could update the other. If you really do need to send data only one way, a named pipe would be sufficient. – chepner Mar 08 '22 at 14:23
  • Do you know how a named pipe can be used to send between the GUI and motion-tracking script? I can make a pipe in the motion-tracking script but can't understand how to link it to the GUI – AMeng Mar 14 '22 at 11:40
  • You treat it like a file. Open it for writing in one script, for reading in the other. Reads will block if the pipe is currently empty until the other writes to it; writes will block if the pipe is full until the other reads from it. – chepner Mar 14 '22 at 13:00
  • Only *one* process has to actually *create* the pipe; ideally, that's something *neither* script is responsible for, but something you create during installation so that both scripts can assume it already exists. – chepner Mar 14 '22 at 13:01
  • So I write the named pipe and then make both processes read the pipe, or just one process must read the pipe while the other writes? – AMeng Mar 15 '22 at 15:00
  • I think are confusing "create the named pipe" with "write to the named pipe". They are two separate actions. For example, in shell you could write something like `mkfifo p1; command1 > p1 & command2 < p1 &`, which is somewhat the same as `command1 | command2`. – chepner Mar 15 '22 at 15:04
  • So this is writing to the named pipe? -- Sorry, I'm actually very new to Python and still trying to wrap my head around everything. Should I create the named Pipe (mkfifo) separately, then write to it from one app and read from another? – AMeng Mar 15 '22 at 15:06
  • I'm curious where you got the idea that you can or should use a named pipe, given your lack of familiarity with them. – chepner Mar 15 '22 at 15:08
  • We contacted the developers of both apps, who recommended using a named pipe - which also seems to be the simplest way to feed data between the apps. Wouldn't normally attempt to do something so out of my depth! – AMeng Mar 15 '22 at 15:13
  • I would *assume*, then, that you just create the fifo, then supply its name as either the input or output file to each script as appropriate. – chepner Mar 15 '22 at 15:19
  • I can create the fifo separately outside of these apps, just in the command prompt/terminal? – AMeng Mar 15 '22 at 15:31

0 Answers0