Commit 5139881c authored by Alain Takoudjou's avatar Alain Takoudjou

fix failure when psutil read info and the process is gone

parent 19e30890
...@@ -428,16 +428,21 @@ def checkPromiseList(promise_dir, promise_timeout, uid=None, gid=None, cwd=None, ...@@ -428,16 +428,21 @@ def checkPromiseList(promise_dir, promise_timeout, uid=None, gid=None, cwd=None,
for current_increment in range(0, increment_limit): for current_increment in range(0, increment_limit):
if process_handler.poll() is None: if process_handler.poll() is None:
if check_profile: if check_profile:
logger.debug( try:
"[t=%ss] CPU: %s%%, MEM: %s MB (%s%%), DISK: %s Read - %s Write" % ( io_counter = psutil_process.io_counters()
current_increment * sleep_time, logger.debug(
psutil_process.cpu_percent(), "[t=%ss] CPU: %s%%, MEM: %s MB (%s%%), DISK: %s Read - %s Write" % (
psutil_process.memory_info().rss / float(2 ** 20), current_increment * sleep_time,
round(psutil_process.memory_percent(), 4), psutil_process.cpu_percent(),
psutil_process.io_counters().read_count, psutil_process.memory_info().rss / float(2 ** 20),
psutil_process.io_counters().write_count round(psutil_process.memory_percent(), 4),
io_counter.read_count,
io_counter.write_count
)
) )
) except (psutil.AccessDenied, psutil.NoSuchProcess):
# defunct process will raise AccessDenied
pass
time.sleep(sleep_time) time.sleep(sleep_time)
continue continue
result_dict["execution-time"] = current_increment * sleep_time result_dict["execution-time"] = current_increment * sleep_time
......
...@@ -37,6 +37,7 @@ class TestGridUtils(unittest.TestCase): ...@@ -37,6 +37,7 @@ class TestGridUtils(unittest.TestCase):
""" """
script = """#!/bin/sh script = """#!/bin/sh
echo "%(name)s" echo "%(name)s"
sleep 0.1
exit %(code)s exit %(code)s
""" """
root_directory = tempfile.mkdtemp() root_directory = tempfile.mkdtemp()
...@@ -74,6 +75,7 @@ exit %(code)s ...@@ -74,6 +75,7 @@ exit %(code)s
""" """
script = """#!/bin/sh script = """#!/bin/sh
echo "%(name)s" echo "%(name)s"
sleep 0.1
exit %(code)s exit %(code)s
""" """
root_directory = tempfile.mkdtemp() root_directory = tempfile.mkdtemp()
...@@ -104,6 +106,7 @@ exit %(code)s ...@@ -104,6 +106,7 @@ exit %(code)s
""" """
script = """#!/bin/sh script = """#!/bin/sh
echo "%(name)s" echo "%(name)s"
sleep 0.1
exit %(code)s exit %(code)s
""" """
root_directory = tempfile.mkdtemp() root_directory = tempfile.mkdtemp()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment