-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with threadpools #113
base: main
Are you sure you want to change the base?
Experiment with threadpools #113
Conversation
check_patch_tornado() | ||
return loop.run_until_complete(coro) | ||
|
||
return pool.submit(asyncio.run, coro).result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have only this line in the function, so that we always run in a thread with its own event loop.
@@ -28,6 +30,7 @@ def check_patch_tornado() -> None: | |||
tornado.concurrent.FUTURES = \ | |||
tornado.concurrent.FUTURES + (asyncio.Future, ) # type: ignore | |||
|
|||
pool = concurrent.futures.ThreadPoolExecutor() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to use more than one thread? I think we should use max_workers=1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max_worker should be fine IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't specify mar_workers
, it will use unnecessary resources: "If max_workers is None or not given, it will default to the number of processors on the machine, multiplied by 5".
Since you never actually run concurrently, you don't need more than 1 thread.
I am seeing many issues with nest-asyncio. Trying out threadpools.