File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
1
from typing import Any , Callable , List
2
2
import logging
3
3
4
+ log = logging .getLogger (__name__ )
5
+
4
6
class Disposables :
5
7
"""A utility class to manage cleanup actions (disposables) in a LIFO order.
6
8
@@ -44,5 +46,5 @@ def cleanup(self) -> None:
44
46
for action in reversed (self ._actions ):
45
47
try :
46
48
action ()
47
- except BaseException as e :
48
- logging . warning ( f"Cleanup action failed: { e } " )
49
+ except BaseException :
50
+ log . exception ( "cleanup action failed" )
Original file line number Diff line number Diff line change @@ -43,10 +43,10 @@ async def _update_environment(self):
43
43
for listener in list (self ._listeners ):
44
44
try :
45
45
listener (env )
46
- except Exception as e :
47
- log .error ( f"Error in environment listener: { e } " )
48
- except BaseException as e :
49
- log .error ( f"Error in environment update: { e } " )
46
+ except Exception :
47
+ log .exception ( "failed to call listener" )
48
+ except BaseException :
49
+ log .exception ( "failed to update environment " )
50
50
51
51
async def _start_update_loop (self ):
52
52
"""Background coroutine that maintains the event stream"""
@@ -86,8 +86,8 @@ async def _start_update_loop(self):
86
86
except BaseException as e :
87
87
if self ._should_stop or isinstance (e , asyncio .CancelledError ):
88
88
break
89
-
90
- log .warning ( f"Error in event stream, retrying in { retry_delay } s: { e } " )
89
+
90
+ log .exception ( "error in event stream, retrying in %s seconds" , retry_delay )
91
91
await asyncio .sleep (retry_delay )
92
92
retry_delay = min (retry_delay * 2 , max_delay )
93
93
You can’t perform that action at this time.
0 commit comments