jacobbridges / cutiepipe

Simple shell utility for named pipes in Linux. Written purely in Python.
0 stars 0 forks source link

Named pipes #3

Open jacobbridges opened 9 years ago

jacobbridges commented 9 years ago

So far cutiepipe only has one main pipe. An important, needed feature is "named pipes". Maybe with the following syntax:

# Some shell session
$ tail -f -n 1 log.txt | cutiepipe -n "apache logs"

# Another shell session
$ cat data.csv | cutiepipe -n data

# Another shell session
$ cutiepipe -n data | python process_data.py
$ cutiepipe -n "apache logs" > log_copy.txt
Blastus commented 9 years ago

If you are working on a network that allows broadcasting, you could have receivers specify their named port and listen for that name to be broadcast on the network. Once the name was broadcast along with a connection address by the sender, the receivers could be given a certain timeout period in which they were allowed to connect to the sender, and the sender would start sending its data to all connected receivers once the timeout period expired.

jacobbridges commented 9 years ago

I apologize for the delayed response, somehow I missed this comment.

Your named pipe implementation is much cleaner than mine--in my idea when a "sending" pipe was created it would also spawn a simple async-server in a separate process which would keep a registry of the pipe names and addresses. It would handle simple communica like "I want to register pipe name "logs" to host=localhost and port=8000" and "Get the address info for sending pipe with name "logs"".

I still think a solution with a separate server would be useful--it would allow receiving pipes to be created after the sender pipe started streaming, not a requirement to be setup first. It would allow for receiving pipes to disconnect and reconnect. But, my troubles with the asyncore library have dissuaded me from the separate server implementation and I'm ready to use your idea.