Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6609

Re: portable way of sending notifying a process

References <4de183e7$0$26108$426a74cc@news.free.fr> <irusph1cdd@news3.newsguy.com>
Date 2011-05-30 12:03 +1000
Subject Re: portable way of sending notifying a process
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2247.1306721004.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, May 30, 2011 at 11:44 AM, Chris Torek <nospam@torek.net> wrote:
>>What would be a light weight portable way, that one process can tell
>>another to do something?
>>
>>The main requirement would be to have no CPU impact while waiting (thus
>>no polling)
>
> Your best bet here is probably to use sockets.  Both systems have
> ways to create service sockets and to connect to a socket as a
> client.

Further to this: If your two processes are going to start up, then run
concurrently for some time, and during that time alert each other (or
one alerts the other) frequently, a socket is an excellent choice. Use
a TCP socket on Windows, and either a TCP socket or a Unix socket on
Linux (I'd just use TCP on both for simplicity, but Unix sockets are
faster), and simply write a byte to it whenever you want to alert the
other side. You can largely guarantee that no other process can
accidentally or maliciously wake you, as long as you have some kind of
one-off handshake on connection - even something really simple like
sending a random nonce, having the other end send hash(nonce +
password), and compare.

Chris Angelico
Huge fan of TCP sockets (hello MUDs!)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

portable way of sending notifying a  process News123 <news1234@free.fr> - 2011-05-29 01:23 +0200
  Re: portable way of sending notifying a  process Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-05-29 00:09 -0700
  Re: portable way of sending notifying a  process Chris Torek <nospam@torek.net> - 2011-05-30 01:44 +0000
    Re: portable way of sending notifying a process Chris Angelico <rosuav@gmail.com> - 2011-05-30 12:03 +1000
      Re: portable way of sending notifying a process News123 <news1234@free.fr> - 2011-05-30 11:18 +0200

csiph-web