# if (i == 0):
# last = not api.Process32First(snapshot, byref(process))
# else:
# last = not api.Process32Next(snapshot, byref(process))
# procname = process.szExeFile
# if procname.decode("utf-8").lower() == name.lower():
# pid = process.th32ProcessID
# break
# if (last):
# break
# i += 1
for proc in psutil.process_iter():
# check whether the process name matches
if proc.name() == name:
pid = proc.pid
break
while 1: