Skip to content

Instantly share code, notes, and snippets.

@tututen

tututen/main.py Secret

Created January 27, 2020 01:48
Show Gist options
  • Save tututen/f847a120f4c585863fc7c288f59997b7 to your computer and use it in GitHub Desktop.
Save tututen/f847a120f4c585863fc7c288f59997b7 to your computer and use it in GitHub Desktop.
concurrentのエラー用
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