File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -78,13 +78,19 @@ def __init__(self):
78
78
self .commands : Dict [int , CommandManager ] = {}
79
79
80
80
try :
81
- loop = asyncio .get_running_loop ()
82
- loop .add_signal_handler (
83
- signal .SIGINT ,
84
- lambda : asyncio .create_task (self ._async_handle_sigint ()),
81
+ try :
82
+ loop = asyncio .get_running_loop ()
83
+ loop .add_signal_handler (
84
+ signal .SIGINT ,
85
+ lambda : asyncio .create_task (self ._async_handle_sigint ()),
86
+ )
87
+ except RuntimeError :
88
+ signal .signal (signal .SIGINT , self ._handle_sigint )
89
+ except ValueError :
90
+ sys .stderr .write (
91
+ "Warning: Unable to set signal handlers in non-main thread. "
92
+ "Ctrl+C handling will be limited.\n "
85
93
)
86
- except RuntimeError :
87
- signal .signal (signal .SIGINT , self ._handle_sigint )
88
94
89
95
async def _async_handle_sigint (self ):
90
96
pids = [
You can’t perform that action at this time.
0 commit comments