Worker caveats
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 42/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Start with the FAQ section and review the linked SVG image demo, especially the ordering of listener registration and the inline image source. Document the listener-ordering caveat for main and worker contexts, with guidance to register bootstrap listeners ahead of time; the FAQ is done when this scenario and the recommended ordering are clear.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I just realized, out of a one-off example in Discord, that if a worker has listeners added after some reference is created or populated with values, the synchronous dance might mislead because that reference on the main might have been already bootstrapped or triggered/resolved.
The explicit issue I am talking about is this one:
image = window.Image.new()
# if this is before, we're all good
image.onload = lambda e: document.body.append(image)
# if that is after though, setting an inline source of the image
# will resolve it before the next `.onload = ...` or even
# `.addEventListener` is attached
image.src = f'data:image/svg+xml;utf8,{svg}'
The demo in case is this one https://pyscript.com/@agiammarchi/svg-image/latest?files=main.py,index.html
I had to double-check why, once added the worker attribute, that would not work.
Due inability to hook into listeners happening on the main, I think it's worth it to document the best way to be sure a listener is triggered, either on main or worker thread, is to define listeners related to such bootstrap AOT (Ahead of Time) and not later.
This is an important detail I could see myself failing at remembering on occasions, so I think it should be part, at least, of our F.A.Q.s section.
- Lingua principale
- Python
- Stelle
- 17
- Fork
- 20
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pyscript/docs
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
Tutte le issue di pyscript/docs
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
bancolombia/sentinel#23 ·
-
test md ApertaCI
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100