Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/radical/asyncflow/workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import signal
import threading
from collections import defaultdict, deque
from functools import wraps
from itertools import count
Expand Down Expand Up @@ -113,6 +114,12 @@ def _setup_signal_handlers(self):
"""
Register signal handlers for graceful shutdown on SIGHUP, SIGTERM, and SIGINT.
"""

# signal handlers are only allowed in the main thread
if threading.current_thread() is not threading.main_thread():
logger.warn(f"Signal handlers can only be set in the main thread")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logger.warn method is deprecated since Python 3.3. It is an alias for logger.warning. It's recommended to use logger.warning for better code maintainability and to align with current best practices.

Suggested change
logger.warn(f"Signal handlers can only be set in the main thread")
logger.warning(f"Signal handlers can only be set in the main thread")

return

signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT)
for sig in signals:
try:
Expand Down