Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As discussed with both @ntoll and @JeffersGlass, we'd love to be able to have multiple terminals on a page through worker attribute, as these are all fresh-new bootstrapped interpreters, these can be interactive too and any constraint regarding the main thread can be easily avoided / ignored.
This MR makes it possible to use 1, 2, or any amount of
<script type="py" worker terminal>
on the same page, being these either bootstrapped all at once or incrementally (dynamically).Changes
sync.is_pyterminal()
utility to understand within hooks if the xworker is actually meant to be used as terminal or it's just a regular worker. By default that returnsfalse
but bootstrapped workers will have it returning truexworker
is also guarded as only once. This is because thesync
properties never need to be assigned twice and also because the terminal itself should never be bootstrapped more than oncetest/py-terminals.html
smoke test that is also used as integration test to live-demo that indeed we can have multiple terminals and no issue whatsoever happens when that's the caseSide Notes
it is very possible that integration tests might fail now because we currently can have multiple terminals ... although previous tests, IIRC, never use the worker attribute and new integration tests have been added so ... maybe we're good to go? I'll wait for CI to tell me somethingI have updated integration tests and I think everything should be fine nowChecklist
CHANGELOG.md