I’ve been mucking around with python for a little while and I have recently come up with something involving multithreading… without further ado… heres what I have…
import pythoncom
import wmi
import threading
class Info(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
pythoncom.CoInitialize()
c = wmi.WMI()
detect = c.Win32_ComputerShutdownEvent.watch_for()
detect()
return
if __name__ == '__main__':
Info().start()
for process in c.Win32_Process(Name="something.exe"):
result = process.Terminate()
So my question is… Why does this work? It may be an overall question regarding the process of the inheritence of threading.Thread… but there is no start() def in the class Info() so why does the run def begin?
This is actually a pretty handy application I needed to use to stop an application that always seems to hang when windows shuts down… finding when the windows shutdown event happens was a bit of a headache but luckily tim golden’s masterpiece saves the day!
Because it’s defined in the parent. Parent classes are checked for attributes if they’re not found (or handled) in the child class.