Skip to content

Commit 3f573dc

Browse files
committed
wraps creation of Semaphore, mutex and counter in the glock
1 parent f43e1a1 commit 3f573dc

File tree

3 files changed

+204
-325
lines changed

3 files changed

+204
-325
lines changed

Modules/_multiprocessing/multiprocessing.c

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ static PyMethodDef module_methods[] = {
191191
* Initialize
192192
*/
193193

194+
extern int _get_timestamp(void) ; // _multiprocesssing.h
195+
194196
static int
195197
multiprocessing_exec(PyObject *module)
196198
{
@@ -230,43 +232,6 @@ multiprocessing_exec(PyObject *module)
230232
}
231233
Py_DECREF(py_sem_value_max);
232234

233-
#ifdef HAVE_BROKEN_SEM_GETVALUE
234-
#include "semaphore_macosx.h"
235-
236-
/* Here define the 2 variables for the workaround about `get_value` method with
237-
the mac OSX semaphore. These variables, a shared memory and a lock must submit
238-
to the resource tracker.
239-
*/
240-
char *p = SHAREDMEM_NAME;
241-
char buf[256];
242-
PyOS_snprintf(buf, sizeof(buf), "%s_%04X", p, getpid());
243-
PyObject *py_shared_mem_name = PyUnicode_FromStringAndSize(buf, strlen(buf));
244-
if (py_shared_mem_name == NULL)
245-
return -1;
246-
if (PyDict_ContainsString(semlock_type->tp_dict, "_MACOSX_SHAREDMEM_NAME") == 0 &&
247-
PyDict_SetItemString(semlock_type->tp_dict, "_MACOSX_SHAREDMEM_NAME",
248-
py_shared_mem_name) < 0) {
249-
Py_DECREF(py_shared_mem_name);
250-
return -1;
251-
}
252-
PyModule_AddStringConstant(module, "_MACOSX_SHAREDMEM_NAME", buf);
253-
Py_DECREF(py_shared_mem_name);
254-
255-
p = GLOCK_NAME;
256-
PyOS_snprintf(buf, sizeof(buf), "%s_%04X", p, getpid());
257-
PyObject *py_glock_mem_name = PyUnicode_FromStringAndSize(buf, strlen(buf));
258-
if (py_glock_mem_name == NULL)
259-
return -1;
260-
if (PyDict_ContainsString(semlock_type->tp_dict, "_MACOSX_GLOCK_NAME") == 0 &&
261-
PyDict_SetItemString(semlock_type->tp_dict, "_MACOSX_GLOCK_NAME",
262-
py_glock_mem_name) < 0) {
263-
Py_DECREF(py_glock_mem_name);
264-
return -1;
265-
}
266-
PyModule_AddStringConstant(module, "_MACOSX_GLOCK_NAME", buf);
267-
Py_DECREF(py_glock_mem_name);
268-
#endif /* HAVE_BROKEN_SEM_GETVALUE*/
269-
270235
#endif
271236

272237
/* Add configuration macros */

0 commit comments

Comments
 (0)