This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2022年03月30日 21:55 by hoodmane, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 32209 | merged | hoodmane, 2022年03月31日 05:00 | |
| Messages (3) | |||
|---|---|---|---|
| msg416403 - (view) | Author: Hood Chatham (hoodmane) | Date: 2022年03月30日 21:55 | |
In Pyodide, we need to patch the interpreter to allow keyboard interrupts. We build Python without pthreads support because Emscripten doesn't currently support using pthreads and dynamic linking in the same build. It is still possible to handle UI at the same time as running Python code by running Python in a web worker. However, the web assembly memory is private to the webworker and cannot be modified from the main thread. The standard way that keyboard interrupts are handled is that the operating system preempts the task to run a signal handler. This can't happen in Emscripten because there is no operating system. Instead, in Emscripten we create a SharedArrayBuffer, share it with the main thread, and then write the signal into this shared memory from the main thread. We patch the main loop to periodically poll this SharedArrayBuffer and if an interrupt has been requested it calls `PyErr_SetInterruptEx` to signal the interrupt. I've set the polling rate to once every 50 interpreter operations, which seems to be reasonably responsive and have a negligible performance cost. One interesting feature of this setup is that it is impossible to create a pointer to the shared memory so it cannot be read directly from C (instead we check it from an `EM_ASM` block). |
|||
| msg416644 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2022年04月03日 20:59 | |
New changeset 087d0fa5b97796560c0d8ceab4f0360fd54baf4f by Hood Chatham in branch 'main': bpo-47176: Interrupt handling for wasm32-emscripten builds without pthreads (GH-32209) https://github.com/python/cpython/commit/087d0fa5b97796560c0d8ceab4f0360fd54baf4f |
|||
| msg416645 - (view) | Author: Christian Heimes (christian.heimes) * (Python committer) | Date: 2022年04月03日 21:04 | |
Thanks for your patch! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:57 | admin | set | github: 91332 |
| 2022年04月03日 21:04:04 | christian.heimes | set | status: open -> closed resolution: fixed messages: + msg416645 stage: patch review -> resolved |
| 2022年04月03日 20:59:23 | christian.heimes | set | messages: + msg416644 |
| 2022年03月31日 17:55:08 | brett.cannon | set | nosy:
+ brett.cannon |
| 2022年03月31日 08:33:58 | christian.heimes | link | issue40280 dependencies |
| 2022年03月31日 08:33:38 | christian.heimes | set | nosy:
+ christian.heimes |
| 2022年03月31日 05:01:52 | hoodchatham | set | versions: + Python 3.11 |
| 2022年03月31日 05:01:22 | hoodchatham | set | versions: - Python 3.10 |
| 2022年03月31日 05:00:07 | hoodmane | set | keywords:
+ patch stage: patch review pull_requests: + pull_request30284 |
| 2022年03月30日 21:55:22 | hoodmane | create | |