bec/bec_lib/tests/test_threadpool.py
2023-08-19 19:58:47 +00:00

13 lines
640 B
Python

from bec_lib.core.singleton_threadpool import SingletonThreadpool
def test_singleton_threadpool():
threadpool = SingletonThreadpool()
assert threadpool.executor._max_workers == SingletonThreadpool.DEFAULT_MAX_WORKER
executor_id = id(threadpool.executor)
new_threadpool = SingletonThreadpool()
assert threadpool.executor._max_workers == SingletonThreadpool.DEFAULT_MAX_WORKER
assert executor_id == id(new_threadpool.executor)
new_threadpool = SingletonThreadpool(max_workers=SingletonThreadpool.DEFAULT_MAX_WORKER + 10)
assert threadpool.executor._max_workers == SingletonThreadpool.DEFAULT_MAX_WORKER + 10