File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 3131
3232logger  =  structlog .get_logger ()
3333
34+ # holder for strong references to pending tasks; remove when the minimum CPython version is one with PR#121264 
35+ background_tasks  =  set ()
36+ 
3437
3538def  parse_args (argv : Sequence [str ] |  None ) ->  argparse .Namespace :
3639    """Parse and return the parsed command line arguments.""" 
@@ -92,13 +95,17 @@ async def start_servers(config: configparser.ConfigParser) -> None:
9295            ircserver  =  IRCServer (config ["irc" ])
9396            irc_coro  =  ircserver .serve ()
9497            irc_task  =  asyncio .create_task (irc_coro )
98+             background_tasks .add (irc_task )
99+             irc_task .add_done_callback (background_tasks .discard )
95100        else :
96101            logger .critical ('Invalid configuration, missing section "irc"' )
97102            raise  SystemExit (- 1 )
98103
99104        if  "rc2udp"  in  config :
100105            rc2udp_coro  =  RC2UDPServer (config ["rc2udp" ], ircserver ).serve ()
101-             rc2udp_task  =  asyncio .create_task (rc2udp_coro )  # noqa: F841 pylint: disable=unused-variable 
106+             rc2udp_task  =  asyncio .create_task (rc2udp_coro )
107+             background_tasks .add (rc2udp_task )
108+             rc2udp_task .add_done_callback (background_tasks .discard )
102109        else :
103110            logger .warning ("RC2UDP is not enabled in the config; server usefulness may be limited" )
104111
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments