BewareMyPower commented on code in PR #16535:
URL: https://github.com/apache/pulsar/pull/16535#discussion_r963478544
##########
pulsar-client-cpp/python/pulsar_test.py:
##########
@@ -1248,6 +1250,35 @@ def test_json_schema_encode(self):
second_encode = schema.encode(record)
self.assertEqual(first_encode, second_encode)
+ def test_logger_thread_leaks(self):
+ def _do_connect(close):
+ logger = logging.getLogger(str(threading.currentThread().ident))
+ logger.setLevel(logging.INFO)
+ client = pulsar.Client(
+ service_url="pulsar://localhost:6650",
+ io_threads=4,
+ message_listener_threads=4,
+ operation_timeout_seconds=1,
+ log_conf_file_path=None,
+ authentication=None,
+ logger=logger,
+ )
+
client.get_topic_partitions("persistent://public/default/partitioned_topic_name_test")
+ if close:
+ client.close()
+
+ for should_close in (True, False):
+ assert threading.active_count() == 1, "Explicit close: {};
baseline is 1 thread".format(should_close)
+ _do_connect(should_close)
+ assert threading.active_count() == 1, "Explicit close: {};
synchronous connect doesn't leak threads".format(should_close)
Review Comment:
```suggestion
self.assertEqual(threading.active_count(), 1, "Explicit close:
{}; baseline is 1 thread".format(should_close))
_do_connect(should_close)
self.assertEqual(threading.active_count(), 1, "Explicit close:
{}; synchronous connect doesn't leak threads".format(should_close))
```
Use `assertEquals` so we can know the current thread count if it failed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]