[python-win32] Technique to limit number of instances of our application under Terminal Server
Tim Golden
mail at timgolden.me.uk
Tue Mar 9 15:18:48 CET 2010
On 09/03/2010 13:19, python at bdurham.com wrote:
> I'm looking for simple ways to monitor and limit the number of
> instances of our Python application that gets run on our in-house
> Terminal Servers (2003 and 2008).
It's not quite clear whether you want something which you
can build into the application itself (in which case, the
answer's probably Semaphores:
http://msdn.microsoft.com/en-us/library/ms685129%28VS.85%29.aspx
or whether you want something external to the applications which
will watch what's starting up and... shut them down, or log an
alert, or something. In which you can probably use WMI events
or a simple polling loop with something like psutil:
http://code.google.com/p/psutil/
I'm not quite sure if you need to distinguish the app when running
in a Terminal Server environment or not...
Obviously there are other approaches: you could write transient pid
files in the Unix fashion, you could use Job objects to group your
processes together in one job:
http://msdn.microsoft.com/en-us/library/ms684161%28VS.85%29.aspx
and limit the number of processes. (I haven't tried this, but in
principle it ought to work).
TJG
More information about the python-win32
mailing list