FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpython/Python/emscripten_signal.c at main · python/cpython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python
/
cpython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
35.3k
Star
74.9k
Code
Issues
5k+
Pull requests
2.5k
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpython
/
Python
/
emscripten_signal.c
Copy path
More file actions
More file actions
Latest commit
History
History
History
54 lines (49 loc) · 1.48 KB
Breadcrumbs
cpython
/
Python
/
emscripten_signal.c
Copy path
File metadata and controls
54 lines (49 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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>
#include
"Python.h"
EM_JS
(
int
,
_Py_CheckEmscriptenSignals_Helper
, (
void
), {
if
(!
Module
.
Py_EmscriptenSignalBuffer
) {
return
0
;
}
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
;
}
});
EMSCRIPTEN_KEEPALIVE
int
Py_EMSCRIPTEN_SIGNAL_HANDLING
=
0
;
void
_Py_CheckEmscriptenSignals
(
void
)
{
if
(!
Py_EMSCRIPTEN_SIGNAL_HANDLING
) {
return
;
}
int
signal
=
_Py_CheckEmscriptenSignals_Helper
();
if
(
signal
) {
PyErr_SetInterruptEx
(
signal
);
}
}
#define
PY_EMSCRIPTEN_SIGNAL_INTERVAL
50
int
_Py_emscripten_signal_clock
=
PY_EMSCRIPTEN_SIGNAL_INTERVAL
;
void
_Py_CheckEmscriptenSignalsPeriodically
(
void
)
{
if
(
_Py_emscripten_signal_clock
==
0
) {
_Py_emscripten_signal_clock
=
PY_EMSCRIPTEN_SIGNAL_INTERVAL
;
_Py_CheckEmscriptenSignals
();
}
else
if
(
Py_EMSCRIPTEN_SIGNAL_HANDLING
) {
_Py_emscripten_signal_clock
--
;
}
}
Back
|
FazBrowse Home
|
New Git URL