-
-
Notifications
You must be signed in to change notification settings - Fork 518
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
Implement built-in threading #2597
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2597 +/- ##
==========================================
+ Coverage 83.27% 83.42% +0.14%
==========================================
Files 190 190
Lines 25008 25134 +126
==========================================
+ Hits 20826 20967 +141
+ Misses 4182 4167 -15
Continue to review full report at Codecov.
|
You might find inspiration in the example provided at #2631 (comment). It's a different approach where you can submit
The vision of that is that somehow multiple threads, processes and frameworks like Dask could be supported and easy to switch between. Maybe even introduce some kind of DAG |
76ae0b4
to
6a3f479
Compare
@MarcSkovMadsen @jbednar @maximlt Please review. |
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.
This will be amazing!
7772033
to
2164949
Compare
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.
This is going in a super nice direction!
I'd suggest to expand the documentation a little, trying to make it clearer what this is all about to people who are not software developers, which I assume (might be wrong!) that it's the majority of Panel users.
- IO bounds vs CPU bounds operations?
- Provide an example for Threading. Two actually ideally, the second one showing how to take advantage of releasing the GIL.
- Are the aysncIO examples actually relevant here? The doc starts by stating that asyncIO is useful in the order of 100 or more operations.
- Does the usage of threading/asyncio mean that an application scale better (i.e. is less affected by an increasing number of users)?
- The Threading section says that whenever an event is generated Panel will dispatch it. It'd be nice to describe in more details what an event is here.
"\n", | ||
"### Threading\n", | ||
"\n", | ||
"Threading in Panel can be enabled easily by setting the `config.nthreads` parameter. This will start a `ThreadPoolExecutor` with the specified number of threads (or if set to `0` it will set the number of threads based on your system, i.e. `min(32, os.cpu_count() + 4)`). Whenever an event is generated or a periodic callback fires Panel will then automatically dispatch the event to the executor. If launching an application with `panel serve` you can configure this option with the `--num-threads` option.\n", |
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.
I did not manage to get threading to work by setting pn.config.nthreads = 4
and launching an app with panel serve app.py
. It did work however with panel serve app.py --num-threads 4
.
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.
Hmm, odd, both should work. Will investigate.
e8d253b
to
63b60b0
Compare
Allows declaring
pn.config.nthreads
and--num-threads
on the CLI which launches aThreadPoolExecutor
to which we dispatch tasks as events arrive from the frontend.