-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into d#/destination_config_updates
# Conflicts: # Makefile # dlt/pipeline/pipeline.py # dlt/pipeline/state_sync.py # tests/pipeline/test_pipeline_state.py
- Loading branch information
Showing
94 changed files
with
6,797 additions
and
5,272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Optional | ||
|
||
import atexit | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
|
||
class ManagedThreadPool: | ||
def __init__(self, max_workers: int = 1) -> None: | ||
self._max_workers = max_workers | ||
self._thread_pool: Optional[ThreadPoolExecutor] = None | ||
|
||
def _create_thread_pool(self) -> None: | ||
assert not self._thread_pool, "Thread pool already created" | ||
self._thread_pool = ThreadPoolExecutor(self._max_workers) | ||
# flush pool on exit | ||
atexit.register(self.stop) | ||
|
||
@property | ||
def thread_pool(self) -> ThreadPoolExecutor: | ||
if not self._thread_pool: | ||
self._create_thread_pool() | ||
return self._thread_pool | ||
|
||
def stop(self, wait: bool = True) -> None: | ||
if self._thread_pool: | ||
self._thread_pool.shutdown(wait=wait) | ||
self._thread_pool = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.