Skip to content

Commit

Permalink
add warning if trying to change max_workers and failing
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonvt committed Dec 4, 2023
1 parent 34061cb commit d8800ef
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cognite/client/utils/_concurrency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import functools
import warnings
from collections import UserList
from concurrent.futures import CancelledError, Future, ThreadPoolExecutor, as_completed
from typing import (
Expand Down Expand Up @@ -196,6 +197,9 @@ def get_thread_pool_executor(cls, max_workers: int) -> ThreadPoolExecutor:
if max_workers < 1:
raise RuntimeError(f"Number of workers should be >= 1, was {max_workers}")
try:
# TODO: Stop-gap, max_workers should move to global_config and become static.
if _THREAD_POOL_EXECUTOR_SINGLETON._max_workers != max_workers:
warnings.warn("Can't change 'max_workers' after first API-call has been made.")
executor = _THREAD_POOL_EXECUTOR_SINGLETON
except NameError:
# TPE has not been initialized
Expand Down

0 comments on commit d8800ef

Please sign in to comment.