10000 bpo-47176: Interrupt handling for wasm32-emscripten builds without pthreads by hoodmane · Pull Request #32209 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-47176: Interrupt handling for wasm32-emscripten builds without pthreads #32209

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

Merged
merged 23 commits into from
Apr 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use EMSCRIPTEN_KEEP_ALIVE in Py_EMSCRIPTEN_SIGNAL_HANDLING, be a bit …
…more conservative with errors in CheckEmscriptenSignals
  • Loading branch information
hoodmane committed Mar 31, 2022
commit baf7b172b0377eee91afd21616219e4d9a80e23d
23 changes: 18 additions & 5 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,14 +1794,28 @@ PyErr_CheckSignals(void)

#if defined(__EMSCRIPTEN__)

// To enable signal handling, the embedder should:
// 1. set Module.Py_EmscriptenSignalBuffer = some_shared_array_buffer;
// 2. set the Py_EMSCRIPTEN_SIGNAL_HANDLING flag to 1 as follows:
// Module.HEAP8[Module._Py_EMSCRIPTEN_SIGNAL_HANDLING] = 1
//
// The address &Py_EMSCRIPTEN_SIGNAL_HANDLING is exported as
// Module._Py_EMSCRIPTEN_SIGNAL_HANDLING.
#include <emscripten.h>
EM_JS(int, _Py_CheckEmscriptenSignals_Helper, (void), {
if(!Module.Py_EmscriptenSignalBuffer){
return 0;
}
let result = Module.Py_EmscriptenSignalBuffer[0];
Module.Py_EmscriptenSignalBuffer[0] = 0;
return result;
try {
let result = Module.Py_EmscriptenSignalBuffer[0];
Module.Py_EmscriptenSignalBuffer[0] = 0;
return result;
} catch(e){
#if !defined(NDEBUG)
console.warn("Error occurred while trying to read signal buffer:", e);
#endif
return 0;
}
});

void
Expand All @@ -1813,8 +1827,7 @@ _Py_CheckEmscriptenSignals(void)
}
}


int Py_EMSCRIPTEN_SIGNAL_HANDLING = 0;
EMSCRIPTEN_KEEP_ALIVE int Py_EMSCRIPTEN_SIGNAL_HANDLING = 0;

#endif

Expand Down
0