我们在项目中使用PyFilesystem。它在Windows 7 x64上运行良好,但在Windows 7 x32上它引发了一个例外:
Exception in thread Thread-28:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 911, in _bootstrap_inner
self.run()
File "C:\environment\lib\site-packages\fs\osfs\watch_win32.py", line 365, in run
-1)
ctypes.ArgumentError: argument 4: <class 'TypeError'>: expected LP_OVERLAPPED instance instead of pointer to OVERLAPPED
发生异常的代码:
...
overlapped = OVERLAPPED()
while not self.closed:
try:
GetQueuedCompletionStatus(self._iocp,
ctypes.byref(nbytes),
ctypes.byref(iocpkey),
ctypes.byref(overlapped),
-1)
except WindowsError:
traceback.print_exc()
...
如果有任何帮助,我将不胜感激。
答案 0 :(得分:0)
我遇到了同样的问题,这是因为在这种情况下有一个其他模块watchdog
定义了同一个函数的args。我建议打印GetQueuedCompletionStatus.argtypes
。这将为您提供有关哪个模块PyFilesystem
存在冲突的提示。
我的输出就是这种情况:
(<class 'ctypes.c_void_p'>, <class 'ctypes.c_void_p'>, <class 'ctypes.c_void_p'>, <class 'watchdog.observers.winapi.LP_OVERLAPPED'>, <class 'ctypes.c_ulong'>)
第4个arg指向watchdog.observers.winapi.LP_OVERLAPPED
,这会引导您解决问题。