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

'Future' object has no attribute 'then' #2923

Closed
karray opened this issue Jul 30, 2022 · 1 comment · Fixed by #2997
Closed

'Future' object has no attribute 'then' #2923

karray opened this issue Jul 30, 2022 · 1 comment · Fixed by #2997
Labels
bug Something isn't working

Comments

@karray
Copy link
Contributor

karray commented Jul 30, 2022

🐛 Bug

If I understand correctly, starting with version 0.17, Pyodide integrates the implementation of await for JsProxy. So when JS returns a Promise, it converts it to Future in Python, which allows us to use await.

Hoverer, the Future object has no attribute then, so it is no longer possible to build then/catch chains like in older versions.

To Reproduce

import js
js.fetch('http://karay.me/truepyxel/test.json').then(lambda resp: resp.json()).then(lambda data: data.msg).catch(lambda err: 'there were error: '+err.message)

Environment

  • Pyodide Version: 0.20
  • Browser version: 103.0.5060.134
@karray karray added the bug Something isn't working label Jul 30, 2022
@hoodmane
Copy link
Member

Yes we should add then, catch, and finally_ methods to the Future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants