[python-win32] Technique to limit number of instances of our application under Terminal Server

python at bdurham.com python at bdurham.com
Fri Mar 12 15:41:19 CET 2010


Hi Tim,

Before continuing I want to express how grateful I am to you and all the
others that have joined this thread. THANK-YOU, THANK-YOU, THANK-YOU!

> Be aware of Christopher Nilsson's point that while the Mutex will be released if the holding process crashes hard, the Semaphore will not release its token. (Haven't tried this myself; I'm assuming he's had experience or has read the docs more carefully than me).

This is actually what I saw, too, but thought it was a subtle problem
with how I coded my tests.

> The bind-to-a-socket approach is a good general-purpose solution. (It can be used on any socket-based system where binding semantics disallow simultaneous connections).

I like this idea (and Windows seems to disallow simultaneous
connections), but at a high level, I'm not sure how managing a pool of
sockets is any different than managing a pool of mutex's? I haven't
tried it yet, but intuitively I would think that a pool of mutex's would
be faster to iterate through and more resource efficient?

Regards,
Malcolm

----- Original message -----
From: "Tim Golden" <mail at timgolden.me.uk>
To: 
Cc: "zz Python Win32 Newsgroup" <python-win32 at python.org>
Date: Fri, 12 Mar 2010 14:31:54 +0000
Subject: Re: [python-win32] Technique to limit number of instances of
our application under Terminal Server

On 12/03/2010 14:21, python at bdurham.com wrote:
> Tim,
>
> Thank you for your example code and ideas!!
>
> I think my earlier experiments with semaphores may be the result of my
> poor code vs. your approach :)
>
> I'm going to put aside my pool of mutex's idea and experiment with your
> sample code.

Good luck. Be aware of Christopher Nilsson's point that while
the Mutex will be released if the holding process crashes hard,
the Semaphore will not release its token. (Haven't tried this
myself; I'm assuming he's had experience or has read the docs
more carefully than me).

The bind-to-a-socket approach is a good general-purpose solution.
(It can be used on any socket-based system where binding semantics
disallow simultaneous connections).

Greg Ewing's "control server" is the kind of thing you'd be doing
for license control, eg, and has the advantage he points out about
detecting dead session. But it has the overhead of a control process.
Which may or may not be an issue for you.

TJG
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list