1515"""
1616Kafka admin client: create, view, alter, and delete topics and resources.
1717"""
18+ import gc
1819import warnings
1920import concurrent .futures
2021from typing import Any , Dict , List , Optional , Union , Tuple , Set
@@ -135,7 +136,6 @@ def _make_topics_result(f: concurrent.futures.Future, futmap: Dict[str, concurre
135136 Map per-topic results to per-topic futures in futmap.
136137 The result value of each (successful) future is None.
137138 """
138- import gc
139139 gc_was_enabled = gc .isenabled ()
140140 gc .disable ()
141141 try :
@@ -166,7 +166,6 @@ def _make_resource_result(f: concurrent.futures.Future,
166166 Map per-resource results to per-resource futures in futmap.
167167 The result value of each (successful) future is a ConfigResource.
168168 """
169- import gc
170169 gc_was_enabled = gc .isenabled ()
171170 gc .disable ()
172171 try :
@@ -201,7 +200,6 @@ def _make_consumer_groups_result(f: concurrent.futures.Future,
201200 """
202201 Map per-group results to per-group futures in futmap.
203202 """
204- import gc
205203 gc_was_enabled = gc .isenabled ()
206204 gc .disable ()
207205 try :
@@ -233,8 +231,6 @@ def _make_consumer_group_offsets_result(f: concurrent.futures.Future,
233231 Map per-group results to per-group futures in futmap.
234232 The result value of each (successful) future is ConsumerGroupTopicPartitions.
235233 """
236- import gc
237-
238234 # Disable GC during callback to prevent AdminClient destruction from librdkafka thread.
239235 # This callback runs in librdkafka's background thread, and if GC runs here, it may
240236 # try to destroy AdminClient objects, which librdkafka forbids from its own threads.
@@ -271,7 +267,6 @@ def _make_acls_result(f: concurrent.futures.Future, futmap: Dict[Any, concurrent
271267 For create_acls the result value of each (successful) future is None.
272268 For delete_acls the result value of each (successful) future is the list of deleted AclBindings.
273269 """
274- import gc
275270 gc_was_enabled = gc .isenabled ()
276271 gc .disable ()
277272 try :
@@ -299,7 +294,6 @@ def _make_acls_result(f: concurrent.futures.Future, futmap: Dict[Any, concurrent
299294 @staticmethod
300295 def _make_futmap_result_from_list (f : concurrent .futures .Future ,
301296 futmap : Dict [Any , concurrent .futures .Future ]) -> None :
302- import gc
303297 gc_was_enabled = gc .isenabled ()
304298 gc .disable ()
305299 try :
@@ -326,7 +320,6 @@ def _make_futmap_result_from_list(f: concurrent.futures.Future,
326320
327321 @staticmethod
328322 def _make_futmap_result (f : concurrent .futures .Future , futmap : Dict [str , concurrent .futures .Future ]) -> None :
329- import gc
330323 gc_was_enabled = gc .isenabled ()
331324 gc .disable ()
332325 try :
0 commit comments