Fix a memory leak inside VariableClient
@@ -91,6 +91,10 @@ class VariableClient:
# Get a future and add the copy function as a callback.
self._call_counter = 0
+ if self._future:
+ # NOTE: Calling 'cancel' prevents a memory leak inside the
+ # ThreadPoolExecutor's queue.
+ self._future.cancel()
self._future = self._async_request()
self._future.add_done_callback(lambda f: self._callback(f.result()))
