Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试同时运行两个函数时出现断言失败和NSInternalInconsistencyException_Python_Multithreading_Python Multithreading - Fatal编程技术网

Python 尝试同时运行两个函数时出现断言失败和NSInternalInconsistencyException

Python 尝试同时运行两个函数时出现断言失败和NSInternalInconsistencyException,python,multithreading,python-multithreading,Python,Multithreading,Python Multithreading,我想同时运行两个函数-show_video()和signature_control()。第一个从摄影机流中读取图像,并使用matplotlib进行打印。第二个连接了一些API,以便根据视频流中检测到的对象触发某些事件。我在教程中看到,我可以同时运行这两个函数,如下所示: if __name__ == '__main__': Thread(target = show_video).start() Thread(target = gesture_control).start() 但

我想同时运行两个函数-show_video()和signature_control()。第一个从摄影机流中读取图像,并使用matplotlib进行打印。第二个连接了一些API,以便根据视频流中检测到的对象触发某些事件。我在教程中看到,我可以同时运行这两个函数,如下所示:

if __name__ == '__main__':
    Thread(target = show_video).start()
    Thread(target = gesture_control).start()
但是我有各种各样的错误

2017-08-04 14:39:05.072 python[9512:693356] WARNING: nextEventMatchingMask should only be called from the Main Thread! This will throw an exception in the future.
2017-08-04 14:39:05.072 python[9512:693356] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.25/Misc.subproj/NSUndoManager.m:363
2017-08-04 14:39:05.075 python[9512:693356] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1349.25/Misc.subproj/NSUndoManager.m:363
2017-08-04 14:39:05.077 python[9512:693356] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'

*** First throw call stack:
(
    0   CoreFoundation                      0x00007fffa45580db __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00007fffb91dfa2a objc_exception_throw + 48
    2   CoreFoundation                      0x00007fffa455cc32 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x00007fffa5fc5d50 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   Foundation                          0x00007fffa5f503f3 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 170
    5   AppKit                              0x00007fffa1ff4047 -[NSApplication run] + 1200
+50 more rows

libc++abi.dylib: terminating with uncaught exception of type NSException

你能解决这个问题吗?