Passing params to single instance of wxApp

Cliff Wells LogiplexSoftware at earthlink.net
Wed Mar 26 01:46:44 CET 2003


On Tue, 2003-03-25 at 15:56, Sam wrote:
> tebeka at cs.bgu.ac.il (Miki Tebeka) wrote in message news:<33803989.0303250410.35e12368 at posting.google.com>...
> > Hello,
> > 
> > > I want my app to only allow one instance, the problem is that it is
> > > associated with a file type so when another of that file type is
> > > opened I end up with two instances. I used the wxSingleInstanceChecker
> > > to stop this from occuring but I really want to pass the params (i.e.
> > > new filename) to the running app.  Any ideas?  
> > I'd use some sort of RPC to notify the other application (TCP/IP with
> > known port?) just before closing the new one.
> > Ugly but should work.
> > 
> > HTH.
> > Miki
> 
> This sounds like it would work but there has to be a better, simpler
> way to do this.  THis is going to be a last resort. Anyone got
> anything better?

Actually, I don't think there is a better way (at least not if
portability matters at all).  But frankly, it's neither *that* ugly nor
difficult.  Take a look at the example in the Python docs for sockets to
get started.

The only real hiccup is in multi-user situations because only one
instance of the app will be able to open the port.  For a single-user
this isn't an issue because you only want one instance anyway, but if
you have two or more users sharing the same machine, only one will be
able to run the app at a time.  You might get around this by selecting a
base range for the port number (say 30000) and adding the uid to it. 
This still doesn't guarantee that no other program is holding the port,
but it reduces the odds a bit.  Under Windows there's no uid (that I
know of), but multiuser isn't really a "problem" there either <wink>.


-- 
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308  (800) 735-0555 x308






More information about the Python-list mailing list