Skip to content

Commit df793d1

Browse files
committed
Added xworker.unstuck() in the docs
1 parent 75a3b30 commit df793d1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ Within a *Worker* execution context, the `xworker` exposes the following feature
550550
| sync | `xworker.sync.from_main(1, "two")` | Executes the exposed `from_main` function in the main thread. Returns synchronously its result when *SharedArrayBuffer* can work synchronously. Returns asynchronously otherwise exposed callbacsk from the *main* thread. |
551551
| window | `xworker.window.document.title = 'Worker'` | Differently from *pyodide* or *micropython* `import js`, this field allows every single possible operation directly in the main thread when that is possible (*SharedArrayBuffer* either available or polyfilled for `sync` operations too). It does not refer to the local `js` environment the interpreter might have decided to expose, it is a proxy to handle otherwise impossible operations in the main thread, such as manipulating the *DOM*, reading `localStorage` otherwise not available in workers, change location or anything else usually possible to do in the main thread. |
552552
| isWindowProxy | `xworker.isWindowProxy(ref)` | **Advanced** - Allows introspection of *JS* references, helping differentiating between local worker references, and main thread global JS references. This is valid both for non primitive objects (array, dictionaries) as well as functions, as functions are also enabled via `xworker.window` in both ways: we can add a listener from the worker or invoke a function in the main. Please note that functions passed to the main thread will always be invoked asynchronously. |
553+
| unstuck | `script.xworker.unstuck()` | On the **main** thread only, hints code running in the Worker that it should throw an error: `while unstuck(True): pass` as example, will exit that loop when on the *main* `xworker.unstuck()` is invoked. See [test/unstuck](https://github.com/pyscript/polyscript/blob/main/test/unstuck/index.html) for a complete example. |
553554
554555
555556
```python

0 commit comments

Comments
 (0)