-
-
Save tututen/f847a120f4c585863fc7c288f59997b7 to your computer and use it in GitHub Desktop.
concurrentのエラー用
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
import concurrent | |
import concurrent.futures | |
def inner_concurrent(num: int): | |
print(f"num = {num}") | |
return num * num | |
def outer_concurrent(): | |
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: | |
futures = [executor.submit(inner_concurrent, i) for i in range(3)] | |
return futures | |
def main(): | |
with concurrent.futures.ProcessPoolExecutor(max_workers=1) as executor: | |
futures = [executor.submit(outer_concurrent) for _ in range(1)] | |
for outer_f in futures: | |
for inner_f in outer_f.result(): | |
print(f"result = {inner_f.result()}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment