def is_mysql_running():
 with open(os.devnull, 'w') as os_devnull:
  returncode = subprocess.call('pgrep mysqld', stdout=os_devnull, shell=True)
 return (returncode == 0)

def is_mysql_running ( ) : with open ( os . devnull , 'w' ) as os_devnull : returncode = subprocess . call ( 'pgrep mysqld' , stdout = os_devnull , shell = True ) return ( returncode == 0 )
returns true if mysql is running .