Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b26a9b1

Browse files
committed
Replace WaitForSingleObject with WaitForSingleObjectEx,
for better WinRT compatibility.
1 parent 3f50bf6 commit b26a9b1

6 files changed

Lines changed: 7 additions & 7 deletions

File tree

Modules/_multiprocessing/semaphore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _GetSemaphoreValue(HANDLE handle, long *value)
4343
{
4444
long previous;
4545

46-
switch (WaitForSingleObject(handle, 0)) {
46+
switch (WaitForSingleObjectEx(handle, 0, FALSE)) {
4747
case WAIT_OBJECT_0:
4848
if (!ReleaseSemaphore(handle, 1, &previous))
4949
return MP_STANDARD_ERROR;
@@ -99,7 +99,7 @@ semlock_acquire(SemLockObject *self, PyObject *args, PyObject *kwds)
9999
}
100100

101101
/* check whether we can acquire without releasing the GIL and blocking */
102-
if (WaitForSingleObject(self->handle, 0) == WAIT_OBJECT_0) {
102+
if (WaitForSingleObjectEx(self->handle, 0, FALSE) == WAIT_OBJECT_0) {
103103
self->last_tid = GetCurrentThreadId();
104104
++self->count;
105105
Py_RETURN_TRUE;

Modules/timemodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ floatsleep(double secs)
15741574
DWORD rc;
15751575
HANDLE hInterruptEvent = _PyOS_SigintEvent();
15761576
ResetEvent(hInterruptEvent);
1577-
rc = WaitForSingleObject(hInterruptEvent, ul_millis);
1577+
rc = WaitForSingleObjectEx(hInterruptEvent, ul_millis, FALSE);
15781578
if (rc == WAIT_OBJECT_0) {
15791579
Py_BLOCK_THREADS
15801580
errno = EINTR;

PC/launcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ run_child(wchar_t * cmdline)
535535
error(RC_CREATE_PROCESS, L"Unable to create process using '%s'", cmdline);
536536
AssignProcessToJobObject(job, pi.hProcess);
537537
CloseHandle(pi.hThread);
538-
WaitForSingleObject(pi.hProcess, INFINITE);
538+
WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE);
539539
ok = GetExitCodeProcess(pi.hProcess, &rc);
540540
if (!ok)
541541
error(RC_CREATE_PROCESS, L"Failed to get exit code of process");

Parser/myreadline.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ my_fgets(char *buf, int len, FILE *fp)
6868
*/
6969
if (GetLastError()==ERROR_OPERATION_ABORTED) {
7070
hInterruptEvent = _PyOS_SigintEvent();
71-
switch (WaitForSingleObject(hInterruptEvent, 10)) {
71+
switch (WaitForSingleObjectEx(hInterruptEvent, 10, FALSE)) {
7272
case WAIT_OBJECT_0:
7373
ResetEvent(hInterruptEvent);
7474
return 1; /* Interrupt */

Python/condvar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ _PyCOND_WAIT_MS(PyCOND_T *cv, PyMUTEX_T *cs, DWORD ms)
242242
* but we are safe because we are using a semaphore wich has an internal
243243
* count.
244244
*/
245-
wait = WaitForSingleObject(cv->sem, ms);
245+
wait = WaitForSingleObjectEx(cv->sem, ms, FALSE);
246246
PyMUTEX_LOCK(cs);
247247
if (wait != WAIT_OBJECT_0)
248248
--cv->waiting;

Python/thread_nt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ FreeNonRecursiveMutex(PNRMUTEX mutex)
130130
DWORD
131131
EnterNonRecursiveMutex(PNRMUTEX mutex, DWORD milliseconds)
132132
{
133-
return WaitForSingleObject(mutex, milliseconds);
133+
return WaitForSingleObjectEx(mutex, milliseconds, FALSE);
134134
}
135135

136136
BOOL

0 commit comments

Comments
 (0)