Skip to content

Commit 2ac2321

Browse files
committed
Go back to Py_CAN_START_THREADS
1 parent fe38ff9 commit 2ac2321

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Include/pyport.h

+8
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,14 @@ extern "C" {
470470
# define WITH_THREAD
471471
#endif
472472

473+
/* Some WebAssembly platforms do not provide a working pthread implementation.
474+
* Thread support is stubbed and any attempt to create a new thread fails.
475+
*/
476+
#if (!defined(HAVE_PTHREAD_STUBS) && \
477+
(!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)))
478+
# define Py_CAN_START_THREADS 1
479+
#endif
480+
473481
#ifdef WITH_THREAD
474482
# ifdef Py_BUILD_CORE
475483
# ifdef HAVE_THREAD_LOCAL

Modules/_testinternalcapi/test_critical_sections.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ thread_critical_sections(void *arg)
170170
}
171171
}
172172

173-
#ifndef HAVE_PTHREAD_STUBS
173+
#ifdef Py_CAN_START_THREADS
174174
static PyObject *
175175
test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args))
176176
{
@@ -201,7 +201,7 @@ static PyMethodDef test_methods[] = {
201201
{"test_critical_sections", test_critical_sections, METH_NOARGS},
202202
{"test_critical_sections_nest", test_critical_sections_nest, METH_NOARGS},
203203
{"test_critical_sections_suspend", test_critical_sections_suspend, METH_NOARGS},
204-
#ifndef HAVE_PTHREAD_STUBS
204+
#ifdef Py_CAN_START_THREADS
205205
{"test_critical_sections_threads", test_critical_sections_threads, METH_NOARGS},
206206
#endif
207207
{NULL, NULL} /* sentinel */

0 commit comments

Comments
 (0)