Skip to content

Commit

Permalink
Improved status reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
PalNilsson committed Sep 8, 2023
1 parent 5094a77 commit 002e3e0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion PILOTVERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.6.21
3.6.6.22
44 changes: 34 additions & 10 deletions pilot/control/payloads/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,7 @@ def stop_utilities(self):
logger.warning(f'did not find the pid for the memory monitor in the utilities list: {self.__job.utilities}')
pid = utproc.pid
status = self.kill_and_wait_for_process(pid, user, utcmd)
if status == 0:
logger.info(f'cleaned up after prmon process {utproc.pid}')
else:
logger.warning(f'failed to cleanup prmon process {utproc.pid} (abnormal exit status: {status})')
logger.info(f'utility process {utproc.pid} cleanup finished with status={status}')
user.post_utility_command_action(utcmd, self.__job)

def kill_and_wait_for_process(self, pid, user, utcmd):
Expand All @@ -887,27 +884,54 @@ def kill_and_wait_for_process(self, pid, user, utcmd):
# Send SIGUSR1 signal to the process
os.kill(pid, sig)

try:
# Check if the process exists
if os.kill(pid, 0):
# Wait for the process to finish
_, status = os.waitpid(pid, 0)

# Check the exit status of the process
if os.WIFEXITED(status):
logger.debug('normal exit')
return os.WEXITSTATUS(status)
else:
# Handle abnormal termination if needed
logger.warning('abnormal termination')
return None
except OSError as exc:
# Handle errors related to waiting for the process
logger.warning(f"error waiting for process {pid}: {exc}")
return None
else:
# Process doesn't exist - ignore
logger.info(f'process {pid} no longer exists')
return True

except OSError as exc:
# Handle errors, such as process not found
logger.warning(f"error sending signal to process {pid}: {exc}")
logger.warning(f"Error sending signal to/waiting for process {pid}: {exc}")
return None

# try:
# # Send SIGUSR1 signal to the process
# os.kill(pid, sig)
#
# try:
# # Wait for the process to finish
# _, status = os.waitpid(pid, 0)
#
# # Check the exit status of the process
# if os.WIFEXITED(status):
# return os.WEXITSTATUS(status)
# else:
# # Handle abnormal termination if needed
# logger.warning('abnormal termination')
# return None
# except OSError as exc:
# # Handle errors related to waiting for the process
# logger.warning(f"error waiting for process {pid}: {exc}")
# return None
#
# except OSError as exc:
# # Handle errors, such as process not found
# logger.warning(f"error sending signal to process {pid}: {exc}")
# return None

# try:
# # Send SIGUSR1 signal to the process
# os.kill(pid, sig)
Expand Down
2 changes: 1 addition & 1 deletion pilot/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RELEASE = '3' # released number should be fixed at 3 for Pilot 3
VERSION = '6' # version number is '1' for first release, '0' until then, increased for bigger updates
REVISION = '6' # revision number should be reset to '0' for every new version release, increased for small updates
BUILD = '21' # build number should be reset to '1' for every new development cycle
BUILD = '22' # build number should be reset to '1' for every new development cycle

SUCCESS = 0
FAILURE = 1
Expand Down

0 comments on commit 002e3e0

Please sign in to comment.