Interprocess communication

Discussion in 'Ruby' started by Jonas Galvez, Jul 12, 2005.

  1. Jonas Galvez

    Jonas Galvez Guest

    I have a Python script running as daemon. I need a way to have a Ruby
    script send a message to it and read a response. I've been reading
    about pipes and fifo but it's all very confusing.

    Just thought I'd ask before trying anything: what's the safest and
    easiest way to accomplish this in Ruby?

    --Jonas Galvez
     
    Jonas Galvez, Jul 12, 2005
    #1
    1. Advertising

  2. Jonas Galvez wrote:
    > I have a Python script running as daemon. I need a way to have a Ruby
    > script send a message to it and read a response. I've been reading
    > about pipes and fifo but it's all very confusing.
    >
    > Just thought I'd ask before trying anything: what's the safest and
    > easiest way to accomplish this in Ruby?


    Depends on which changes you can do to the python script. Does it offer
    some kind of messaging functionality already?

    If you can start from scratch (for example because you have to change the
    phython script anyway) you can do any of these:

    - make the python script open a pair of named pipes, one for reading and
    one for writing answers. This works good only if you do have just a
    single client (your ruby script)

    - make the phython script open a unix domain socket (which is accessible
    only from localhost). That way you can have several clients connect but
    your phython script must handle these.

    - dedicate a directory for exchange of messages via files. You then need
    some kind of locking and a protocol, who writes which files there etc.

    It really depends on your situation and requirements. If you provide more
    input we might be able to come up with a more concrete suggestion.

    Kind regards

    robert
     
    Robert Klemme, Jul 12, 2005
    #2
    1. Advertising

  3. Jonas Galvez

    Dido Sevilla Guest

    On 7/12/05, Jonas Galvez <> wrote:
    > I have a Python script running as daemon. I need a way to have a Ruby
    > script send a message to it and read a response. I've been reading
    > about pipes and fifo but it's all very confusing.
    >=20
    > Just thought I'd ask before trying anything: what's the safest and
    > easiest way to accomplish this in Ruby?


    The simplest (not necessarily the best, that would on your
    application's exact requirements, of which you've given us few
    details), I think, would be to use XML-RPC. There are mature and
    well-tested XML-RPC libraries for both Ruby and Python (for Python, I
    believe it's integrated into the language's standard libraries
    already). Set your Python script to be an XML-RPC server, and Ruby to
    be your XML-RPC client and off you go. This ought to work even if your
    Ruby and Python scripts are running on different computers, but it's a
    fairly heavyweight approach.
     
    Dido Sevilla, Jul 13, 2005
    #3
  4. > The simplest (not necessarily the best, that would on your
    > application's exact requirements, of which you've given us few
    > details), I think, would be to use XML-RPC. There are mature and
    > well-tested XML-RPC libraries for both Ruby and Python (for Python, I
    > believe it's integrated into the language's standard libraries
    > already). Set your Python script to be an XML-RPC server, and Ruby to
    > be your XML-RPC client and off you go. This ought to work even if your
    > Ruby and Python scripts are running on different computers, but it's a
    > fairly heavyweight approach.
    >=20


    You could of course use the principles of OO and abstract that away,
    perhaps providing a shared memory impl as well as the XML-RPC.




    --=20
    Into RFID? www.rfidnewsupdate.com Simple, fast, news.
     
    Lyndon Samson, Jul 13, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Swapnajit Mittra
    Replies:
    0
    Views:
    444
    Swapnajit Mittra
    Dec 21, 2004
  2. Dave Bartlett

    newbie question: interprocess communication

    Dave Bartlett, May 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    494
    DalePres
    May 13, 2004
  3. James  Aguilar
    Replies:
    3
    Views:
    551
    Aguilar, James
    Dec 20, 2005
  4. Michael Butscher
    Replies:
    7
    Views:
    346
    Lawrence D'Oliveiro
    Jul 1, 2006
  5. exhuma.twn
    Replies:
    23
    Views:
    1,032
    Steve Holden
    Feb 18, 2007
Loading...

Share This Page