From ff618a541a0b45b84b2495b2f87430ce28baf318 Mon Sep 17 00:00:00 2001
From: Nikita Nemkin <nikita@nemkin.ru>
Date: Thu, 2 Jun 2011 01:19:44 +0600
Subject: [PATCH] Replaced WMI process enumeration with the EnumProcesses API call.
(Shorter, faster, does not depend on pythoncom.)
---
deluge/core/daemon.py | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py
index 0343feb..c6e63a8 100644
a
|
b
|
def __init__(self, options=None, args=None, classic=False):
|
66 | 66 | |
67 | 67 | def process_running(pid): |
68 | 68 | if deluge.common.windows_check(): |
69 | | # Do some fancy WMI junk to see if the PID exists in Windows |
70 | | from win32com.client import GetObject |
71 | | def get_proclist(): |
72 | | WMI = GetObject('winmgmts:') |
73 | | processes = WMI.InstancesOf('Win32_Process') |
74 | | return [process.Properties_('ProcessID').Value for process in processes] |
75 | | return pid in get_proclist() |
| 69 | import win32process |
| 70 | return pid in win32process.EnumProcesses() |
76 | 71 | else: |
77 | 72 | # We can just use os.kill on UNIX to test if the process is running |
78 | 73 | try: |