Details
-
Type:
Story
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Story Points:0
-
Epic Link:
-
Sprint:TSSW Sprint - Aug 28 - Sep 11
-
Team:Telescope and Site
-
Urgent?:No
Description
Please consider making lsst.ts.common.BaseDataClient into an async context manager by adding __aenter__ and ___aexit__ methods. This would only be used by unit tests and I'm not completely sure how much it will help. But at least have a look.
It will look like this:
async def __aenter__(self) -> BaseDataClient:
|
await self.start()
|
return self
|
|
async def __aexit__(
|
self,
|
type: typing.Type[BaseException] | None,
|
value: BaseException | None,
|
traceback: types.TracebackType | None,
|
) -> None:
|
await self.stop()
|
I suggest trying to use it in some unit tests to sanity-check whether it is a good idea.
I implemented this and it works. This could be used in ts_ess_csc but I won't implement that for now.