Skip to content

Commit

Permalink
fix: dispose window scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar committed Feb 2, 2024
1 parent 2d91db5 commit f64aa8e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion influxdb_client/client/write_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ def __init__(self,
# Define Subject that listen incoming data and produces writes into InfluxDB
self._subject = Subject()

self._window_scheduler = ThreadPoolScheduler(1)
self._disposable = self._subject.pipe(
# Split incoming data to windows by batch_size or flush_interval
ops.window_with_time_or_count(count=write_options.batch_size,
timespan=timedelta(milliseconds=write_options.flush_interval),
scheduler=ThreadPoolScheduler(1)),
scheduler=self._window_scheduler),
# Map window into groups defined by 'organization', 'bucket' and 'precision'
ops.flat_map(lambda window: window.pipe(
# Group window by 'organization', 'bucket' and 'precision'
Expand Down Expand Up @@ -440,6 +441,11 @@ def __del__(self):
)
break

if self._window_scheduler:
self._window_scheduler.executor.shutdown()
self._window_scheduler.executor = None
self._window_scheduler = None

if self._disposable:
self._disposable = None
pass
Expand Down Expand Up @@ -565,6 +571,7 @@ def __getstate__(self):
# Remove rx
del state['_subject']
del state['_disposable']
del state['_window_scheduler']
del state['_write_service']
return state

Expand Down

0 comments on commit f64aa8e

Please sign in to comment.