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

pygbag crashes due to async #191

Closed
aramshiva opened this issue Jan 23, 2025 · 2 comments
Closed

pygbag crashes due to async #191

aramshiva opened this issue Jan 23, 2025 · 2 comments
Labels

Comments

@aramshiva
Copy link

aramshiva commented Jan 23, 2025

I am trying to take this boids code and run pygbag on it:
https://gist.github.com/aramshiva/0239dd63a400fc6cc748301aba567203

Though in pygbag, when running in the debug (?-i) mode it gives the following:

1153: scan_imports hint=PosixPath('/data/data/boid/assets/main.py') filename='<stdin>' len(code)=12852 ['numpy']
635: maybe_wanted=['numpy'] known failed aio.pep0723.hint_failed=[]
282: searching numpy
76: fopen: fetching "http://localhost:8000/archives/repo/cp312/numpy-1.26.4-cp312-cp312-emscripten_3_1_52_wasm32.whl#"
142: /tmp/numpy-1.26.4-cp312-cp312-emscripten_3_1_52_wasm32.whl installed
715: starting shell
1039: 301 lines queued for async eval
going interactive
746: TODO detect input/print to select repl debug
  File "<console>", line 243
SyntaxError: 'await' outside async function

I don't use await anywhere and I get the same error when I remove all async code entierly. It displays just a black screen. This seems to be a bug or something not compatible?

@pmp-p
Copy link
Member

pmp-p commented Jan 23, 2025

you cannot run synchronous code on web, you need to at least sleep each 16 milliseconds with eg 'await asyncio.sleep(0)' in any long running loop

https://pygame-web.github.io/showroom/pythongit.html#https://gist.githubusercontent.com/pmp-p/03c95ff6919936664ffe9810337b6fdb/raw/16d5c414a0727e8b9dd185301b664368e5eff5b6/main.py

@pmp-p pmp-p added the usage label Jan 23, 2025
@aramshiva
Copy link
Author

Oops. That makes more sense.

Thanks.

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