Skip to content
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

Bound async method not working: AttributeError: 'App' object has no attribute '_depends' #4261

Closed
MarcSkovMadsen opened this issue Jan 8, 2023 · 2 comments
Labels

Comments

@MarcSkovMadsen
Copy link
Collaborator

I'm on the current main branch.

import asyncio

import param

import panel as pn

class App(param.Parameterized):
    run = param.Event()
    clicks = param.Integer(-1)

    @pn.depends("run")
    async def click_view(self):
        self.clicks+=1
        await asyncio.sleep(0.5)
        return f"Clicked {self.clicks} times"

app=App()
pn.Column(app.param.run, app.click_view).servable()

image

AttributeError: 'App' object has no attribute '_depends'
Traceback (most recent call last):
  File "C:\repos\private\panel\.venv\lib\site-packages\bokeh\application\handlers\code_runner.py", line 231, in run
    exec(self._code, module.__dict__)
  File "C:\repos\private\panel\script.py", line 18, in <module>
    pn.Column(app.param.run, app.click_view).servable()
  File "c:\repos\private\panel\panel\layout\base.py", line 630, in __init__
    params['objects'] = [panel(pane) for pane in objects]
  File "c:\repos\private\panel\panel\layout\base.py", line 630, in <listcomp>
    params['objects'] = [panel(pane) for pane in objects]
  File "c:\repos\private\panel\panel\pane\base.py", line 80, in panel
    pane = PaneBase.get_pane_type(obj, **kwargs)(obj, **kwargs)
  File "c:\repos\private\panel\panel\param.py", line 786, in __init__
    self._link_object_params()
  File "c:\repos\private\panel\panel\param.py", line 864, in _link_object_params
    params = parameterized.param.method_dependencies(self.object.__name__)
  File "C:\repos\private\panel\.venv\lib\site-packages\param\parameterized.py", line 2271, in method_dependencies
    method = getattr(self_.self_or_cls, name)
AttributeError: 'App' object has no attribute '_depends'
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Jan 8, 2023

If I change the click_view method to a function It does not raise an exception, BUT it does not display the value either.

import param

import panel as pn

class App(param.Parameterized):
    run = param.Event()
    clicks = param.Integer(-1)

app=App()

@pn.depends(app.param.run)
async def click_view(_):
    app.clicks+=1
    return f"Clicked {app.clicks} times"

pn.Column(app.param.run, click_view).servable()

image

@MarcSkovMadsen MarcSkovMadsen added this to the v0.14.3 milestone Jan 8, 2023
@MarcSkovMadsen MarcSkovMadsen changed the title Async method not working: AttributeError: 'App' object has no attribute '_depends' Bound async method not working: AttributeError: 'App' object has no attribute '_depends' Jan 9, 2023
@philippjfr
Copy link
Member

Duplicate of #4237

@philippjfr philippjfr marked this as a duplicate of #4237 Jan 26, 2023
@philippjfr philippjfr removed this from the v0.14.3 milestone Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants