#NEWLINE# def check_pid( self , pid ) : #NEWLINE# #INDENT# if ( os . name == 'nt' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import ctypes #NEWLINE# p = ctypes . windll . kernel32 . OpenProcess ( 1 , 0 , pid ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . log . warn ( ( 'Could not determine whether pid %i is running via `OpenProcess`.  Making the likely assumption that it is.' % pid ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# return bool ( p ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# p = Popen ( [ 'ps' , 'x' ] , stdout = PIPE , stderr = PIPE ) #NEWLINE# ( output , _ ) = p . communicate ( ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# self . log . warn ( ( 'Could not determine whether pid %i is running via `ps x`.  Making the likely assumption that it is.' % pid ) ) #NEWLINE# return True #NEWLINE# #UNINDENT# pids = list ( map ( int , re . findall ( '^\\W*\\d+' , output , re . MULTILINE ) ) ) #NEWLINE# return ( pid in pids )