292 def running_pids(self, process_name_filter=None):
293 if not process_name_filter:
294 process_name_filter = lambda process_name: True
295
296 running_pids = []
297
298 if sys.platform in ("win32", "cygwin"):
299 raise NotImplemented()
300
301 ps_process = self.popen(['ps', '-eo', 'pid,comm'], stdout=self.PIPE, stderr=self.PIPE)
302 stdout, _ = ps_process.communicate()
303 for line in stdout.splitlines():
304 try:
305 pid, process_name = line.split(' ', 1)
306 if process_name_filter(process_name):
307 running_pids.append(int(pid))
308 except ValueError, e:
309 pass
310
311 return sorted(running_pids)
312
313 def wait_newest(self, process_name_filter=None):
314 if not process_name_filter:
315 process_name_filter = lambda process_name: True
316
317 running_pids = self.running_pids(process_name_filter)
318 if not running_pids:
319 return
320 pid = running_pids[-1]
321
322 while self.check_running_pid(pid):
323 time.sleep(0.25)
324