-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import random | ||
import time | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
from halo import Halo | ||
|
||
|
||
def long_running_task(i): | ||
with Halo(f"Running {i}", spinner="dots") as sp: | ||
time.sleep(3 + random.random()) | ||
sp.succeed(f"Success {i}") | ||
|
||
|
||
with ThreadPoolExecutor(max_workers=4) as pool: | ||
# Number of tasks is greater than max workers | ||
pool.map(long_running_task, range(8)) |
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