Best Python code snippet using fMBT_python
fmbttestutils.py
Source:fmbttestutils.py
...32 """Returns True if a process with PID is running, otherwise False"""33 if os.name == "nt":34 return _pid_exists_on_windows(pid)35 else:36 return _pid_exists_on_linux(pid)37def _pid_exists_on_linux(pid):38 try:39 os.kill(pid, 0)40 except OSError, e:41 if e.errno == 3:42 return False43 return True44def _pid_exists_on_windows(pid):45 ERROR_ACCESS_DENIED = 546 PROCESS_QUERY_LIMITED_INFORMATION = 0x100047 hProc = ctypes.windll.kernel32.OpenProcess(48 PROCESS_QUERY_LIMITED_INFORMATION, False, pid)49 if hProc == 0:50 if ctypes.windll.kernel32.GetLastError() == 5:51 # Access denied, process exists...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!