🧪 Add new concurrent test directory
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from typing import Any
|
||||
|
||||
|
||||
def get_item(item: Any) -> str:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
items = [1, 2, 3, 4]
|
||||
result = []
|
||||
with ThreadPoolExecutor(max_workers=8) as executor:
|
||||
futures = []
|
||||
for item in items:
|
||||
futures.append(executor.submit(get_item, item))
|
||||
|
||||
for future in as_completed(futures):
|
||||
result.append(future.result())
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user