Skip to content

Commit

Permalink
827 del impl client sdk (#828)
Browse files Browse the repository at this point in the history
implemented `__del__` for ClientSDK
  • Loading branch information
bwsw authored Aug 5, 2024
1 parent d724962 commit e83569a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions savant/client/runner/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def __init__(
self._source = self._build_zeromq_source(socket, receive_timeout, receive_hwm)
self._source.start()

def __del__(self):
logger.info('Terminating ZeroMQ connection')
self._source.terminate()

@abstractmethod
def _build_zeromq_source(self, socket: str, receive_timeout: int, receive_hwm: int):
pass
Expand Down
8 changes: 8 additions & 0 deletions savant/client/runner/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def __init__(
self._pipeline.sampling_period = 1
self._writer.start()

def __del__(self):
logger.info('Terminating ZeroMQ connection')
self._writer.shutdown()

def __call__(self, source: Frame, send_eos: bool = True) -> SourceResult:
"""Send a single frame to ZeroMQ socket.
Expand Down Expand Up @@ -275,6 +279,10 @@ class AsyncSourceRunner(SourceRunner):

_writer: NonBlockingWriter

def __del__(self):
logger.info('Terminating ZeroMQ connection')
self._writer.shutdown()

async def __call__(self, source: Frame, send_eos: bool = True) -> SourceResult:
return await self.send(source, send_eos)

Expand Down

0 comments on commit e83569a

Please sign in to comment.