Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-38876

Consider making BaseDataClient an async context manager

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      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.

        Attachments

          Activity

          Hide
          wvreeven Wouter van Reeven added a comment - - edited

          I implemented this and it works. This could be used in ts_ess_csc but I won't implement that for now.

          Show
          wvreeven Wouter van Reeven added a comment - - edited I implemented this and it works. This could be used in ts_ess_csc but I won't implement that for now.
          Hide
          wvreeven Wouter van Reeven added a comment -
          Show
          wvreeven Wouter van Reeven added a comment - ts_ess_common PR: https://github.com/lsst-ts/ts_ess_common/pull/48
          Hide
          ecoughlin Eric Coughlin added a comment -

          Reviewed on GitHub.

          Show
          ecoughlin Eric Coughlin added a comment - Reviewed on GitHub.

            People

            Assignee:
            wvreeven Wouter van Reeven
            Reporter:
            rowen Russell Owen
            Reviewers:
            Eric Coughlin
            Watchers:
            Eric Coughlin, Russell Owen, Wouter van Reeven
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.