Reputation: 3412
I plan to use Unix named pipes (mkfifo) for simple multi-process messaging. A message would be just a single line of text.
Would you discourage me from that? What obstacles should I expect?
I have noticed these limitations:
I will implement the messaging in Python. But the obstacles hold in general.
Upvotes: 2
Views: 6939
Reputation: 13521
As to your limitations,
I find perlipc to be a good discussion between the various options, though it has perl specific code.
Upvotes: 5
Reputation: 204668
The blocking, both on the sender side and the receiver side, can be worked around via non-blocking I/O.
Further limitations of FIFOs:
I would use UNIX domain sockets instead, which have none of the above limitations.
As an added benefit, if you want to scale it to communicate between multiple machines, it's barely any change at all. For example, just take the Python documentation page on socket and replace socket.AF_INET
with socket.AF_UNIX
, (HOST, PORT)
with filename
, and it just works.
SOCK_STREAM
will give you stream-like behavior; that is, two sends may be merged into one receive or vice versa. AF_UNIX
also supports SOCK_DGRAM
: datagrams are guaranteed to be sent and read all as one unit or not at all. (Analogously, AF_INET
+SOCK_STREAM
=TCP, AF_INET
+SOCK_DGRAM
=UDP.)
Upvotes: 4