Skip to content

Commit 1598c82

Browse files
Fix for broken PrimProc.
1 parent a09a9bb commit 1598c82

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

cmapi/cmapi_server/managers/process.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -254,38 +254,33 @@ def _wait_for_DMLProc_stop(cls, timeout: int = DMLPROC_SHUTDOWN_TIMEOUT) -> bool
254254
:rtype: bool
255255
"""
256256
logging.info(f'Waiting for DMLProc to stop in {timeout} seconds')
257-
# Use a deadline-based loop with throttled logging to reduce noise.
258257
deadline = time.monotonic() + max(1, int(timeout))
259-
LOG_INTERVAL = 30 # seconds
260-
next_log_in = 0 # log immediately on first iteration
258+
# Log at most every 5 seconds while polling every ~1s for responsiveness
259+
LOG_INTERVAL_SEC = 5.0
260+
next_log_at = time.monotonic() # log immediately on first iteration
261261

262262
while True:
263-
remaining = int(deadline - time.monotonic())
263+
now = time.monotonic()
264+
remaining = deadline - now
264265
if remaining <= 0:
265266
break
266267

267268
if not Process.check_process_alive('DMLProc'):
268269
logging.info('DMLProc gracefully stopped by DBRM command.')
269270
return True
270271

271-
# Throttle waiting logs to roughly once every LOG_INTERVAL seconds
272-
if next_log_in <= 0:
273-
sleep_for = min(10, remaining)
272+
if now >= next_log_at:
274273
logging.info(
275-
(
276-
f'Waiting for DMLProc to stop. Seconds left ~{remaining}. '
277-
f'Sleeping {sleep_for} seconds before next check.'
278-
)
274+
f'Waiting for DMLProc to stop. Seconds left ~{int(remaining)}.'
279275
)
280-
next_log_in = LOG_INTERVAL
276+
next_log_at = now + LOG_INTERVAL_SEC
281277

282-
sleep_for = min(10, remaining)
283-
sleep(sleep_for)
284-
next_log_in -= sleep_for
278+
# Sleep in small increments to minimize over-wait after process exit
279+
sleep(min(1.0, max(0.1, remaining)))
285280

286281
logging.error(
287-
'DMLProc didn\'t stop gracefully by DBRM command within '
288-
f'{timeout} seconds. Will be stopped directly.'
282+
"DMLProc didn't stop gracefully by DBRM command within "
283+
f"{int(timeout)} seconds. Will be stopped directly."
289284
)
290285
return False
291286

0 commit comments

Comments
 (0)