user2536262
user2536262

Reputation: 279

Looking at the task manager

I'm writing a program that is supposed to synchronize several different parts, including hardware. This is done by using a python script that communicates with other programs.

I've found out that something I need for synchronization is for the main script to be able to tell if another particular program is running, or if it stops.

I imagine it would look someting like:

#checking if a program runs

if is_running(program):
    statements

#Waiting for a program to stop

while is_running(program):
    pass

Does anyone know? I'm using Python 2.7 on Windows 7.

Upvotes: 2

Views: 1421

Answers (1)

debianplebian
debianplebian

Reputation: 92

This question is pretty similar to your situation, and suggests using WMI which will run on python 2.4 to 3.2 and Windows 7, or using the builtin wmic to get the list of proc.

If you care about making the code cross platform, you could also use psutil, which works on "Linux, Windows, OSX, FreeBSD and Sun Solaris, both 32-bit and 64-bit architectures, with Python versions from 2.4 to 3.4."

Upvotes: 1

Related Questions