-
-
Notifications
You must be signed in to change notification settings - Fork 529
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
pn.Param multi-threading race condition #7564
Comments
@Dsolnik have you tried making import time
import panel as pn
import param
pn.extension(nthreads=10)
class Picker(param.Parameterized):
selection = param.Selector(objects=['a', 'b', 'c'], default='a')
@param.depends('selection', watch=True)
async def on_change(self):
print("BEFORE TIME SLEEP")
time.sleep(2)
print("AFTER TIME SLEEP")
def pane(self):
return pn.Row(self.param.selection.rx())
picker = Picker()
pn.Column(picker.pane(), pn.Param(picker)).servable()
# panel serve --autoreload script.py panel.issue.7564.mov |
Thanks for the response! It makes sense that changing the callback to async would allow it to be queued. I wish I was able to control that. What I'm actually doing is linking together the picker through reactive expressions. @pierrotsmnrd, Do you know if Is there an easy way to make a reactive expression operate like an async watcher here? import time
import panel as pn
import param
pn.extension(nthreads=10)
class Picker(param.Parameterized):
selection = param.Selector(objects=['a', 'b', 'c'], default='a')
class View(param.Parameterized):
selection = param.Selector(objects=['a', 'b', 'c'], default='a', allow_refs=True)
def pane(self):
return pn.Row(self.param.selection.rx())
picker = Picker()
def get_data(x):
# time intensive operation
time.sleep(2)
return x
view = View(selection=picker.param.selection.rx.pipe(get_data).rx())
pn.Column(view.pane(), pn.Param(picker)).servable() |
Making async def get_data(x):
# time intensive operation
time.sleep(2)
return x |
Thanks for the super detailed writeup here. While |
Description of expected behavior and the observed behavior
I would like to have every manual change to a selector change the linked parameter. I would like
pn.Param
to behave consistently ifnthreads=1
ornthreads>1
If you have a multi-threaded app using
pn.Param
, it can happen that:A
.B
.In this case, it's likely the second change will probably be skipped if the
link_widget
callback is called before the update changes. because inpn.Param
, we skip the update if there is currently an update in progress for that parameter:panel/panel/param.py
Line 522 in d48c45f
Complete, minimal, self-contained example code that reproduces the issue
Please note that if you set
nthreads=1
in the previous example, everything works fine :)Screenshots or screencasts of the bug in action
The text was updated successfully, but these errors were encountered: