Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle different pointer size on x64 Windows

WindowsParentPoller makes a winapi call, and needs to handle
32/64b pointer difference.

This commit adds switching of c_int vs c_int64, depending on
platform.architecture().

It also prevents hogging CPU by adding a short sleep in possible
cases where the call still fails.

closes gh-588
  • Loading branch information...
commit 8398813ffc0159e21a878c04d346188e46d2bba1 1 parent 53d497b
@minrk authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 IPython/zmq/parentpoller.py
View
10 IPython/zmq/parentpoller.py
@@ -1,6 +1,7 @@
# Standard library imports.
import ctypes
import os
+import platform
import time
from thread import interrupt_main
from threading import Thread
@@ -100,12 +101,14 @@ def run(self):
handles.append(self.interrupt_handle)
if self.parent_handle:
handles.append(self.parent_handle)
+ arch = platform.architecture()[0]
+ c_int = ctypes.c_int64 if arch.startswith('64') else ctypes.c_int
# Listen forever.
while True:
result = ctypes.windll.kernel32.WaitForMultipleObjects(
len(handles), # nCount
- (ctypes.c_int * len(handles))(*handles), # lpHandles
+ (c_int * len(handles))(*handles), # lpHandles
False, # bWaitAll
INFINITE) # dwMilliseconds
@@ -117,3 +120,8 @@ def run(self):
elif handle == self.parent_handle:
os._exit(1)
+ elif result < 0:
+ # wait failed, but don't let this throttle CPU
+ # if this is going to repeat, perhaps we should
+ # just give up and return.
+ time.sleep(.1)
Please sign in to comment.
Something went wrong with that request. Please try again.