File tree 1 file changed +12
-10
lines changed 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,7 @@ async def run(
491
491
# the initialization lifecycle, but can do so with any available node
492
492
# rather than requiring initialization for each connection.
493
493
stateless : bool = False ,
494
+ timeout : int = 60
494
495
):
495
496
async with AsyncExitStack () as stack :
496
497
lifespan_context = await stack .enter_async_context (self .lifespan (self ))
@@ -504,16 +505,17 @@ async def run(
504
505
)
505
506
506
507
async with anyio .create_task_group () as tg :
507
- async for message in session .incoming_messages :
508
- logger .debug (f"Received message: { message } " )
509
-
510
- tg .start_soon (
511
- self ._handle_message ,
512
- message ,
513
- session ,
514
- lifespan_context ,
515
- raise_exceptions ,
516
- )
508
+ with anyio .move_on_after (timeout ) as scope :
509
+ async for message in session .incoming_messages :
510
+ logger .debug (f"Received message: { message } " )
511
+
512
+ tg .start_soon (
513
+ self ._handle_message ,
514
+ message ,
515
+ session ,
516
+ lifespan_context ,
517
+ raise_exceptions ,
518
+ )
517
519
518
520
async def _handle_message (
519
521
self ,
You can’t perform that action at this time.
0 commit comments