Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better way to check pid and it's cross-platform #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spearmint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
# to enter into this License and Terms of Use on behalf of itself and
# its Institution.


import sys
import optparse
import importlib
Expand Down Expand Up @@ -273,6 +274,7 @@ def main():
# Note: I chose to fill up one resource and them move on to the next
# You could also do it the other way, by changing "while" to "if" here

remove_broken_jobs(db, jobs, experiment_name, resources)
while resource.acceptingJobs(jobs):

# Load jobs from DB
Expand Down
12 changes: 4 additions & 8 deletions spearmint/schedulers/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
import os
import subprocess
import sys
import psutil

def init(*args, **kwargs):
return LocalScheduler(*args, **kwargs)
Expand Down Expand Up @@ -228,12 +229,7 @@ def submit(self, job_id, experiment_name, experiment_dir, database_address):


def alive(self, process_id):
try:
# Send an alive signal to proc (note this could kill it in windows)
os.kill(process_id, 0)
except OSError:
# Job is no longer running.
return False
else:
return True
# todo: not correct to check pid b/c it could be taken by
# another program .
return psutil.pid_exists(process_id)