问题描述
我正在尝试在Windows上运行 python-gasp ,但是当我这样做时import gasp; gasp.begin_graphics()
我得到以下回溯:
I'm trying to get python-gasp working on Windows, but when I do import gasp; gasp.begin_graphics()
I get the following traceback:
File "C:\Python26\lib\site-packages\gasp\backend.py", line 142, in create_screen
screen.updater.start()
File "C:\Python26\lib\multiprocessing\process.py", line 104, in start
self._popen = Popen(self)
File "C:\Python26\lib\multiprocessing\forking.py", line 239, in __init__
dump(process_obj, to_child, HIGHEST_PROTOCOL)
File "C:\Python26\lib\multiprocessing\forking.py", line 162, in dump
ForkingPickler(file, protocol).dump(obj)
File "C:\Python26\lib\pickle.py", line 224, in dump
self.save(obj)
File "C:\Python26\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python26\lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python26\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python26\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python26\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python26\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python26\lib\pickle.py", line 725, in save_inst
save(stuff)
File "C:\Python26\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python26\lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python26\lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python26\lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python26\lib\pickle.py", line 396, in save_reduce
save(cls)
File "C:\Python26\lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python26\lib\pickle.py", line 748, in save_global
(obj, module, name))
PicklingError: Can't pickle <class 'multiprocessing.process._MainProcess'>: it's not found as multiprocessing.process._MainProcess
有人知道为什么我在Windows XP而不是Ubuntu Linux 9.04上出现此错误吗?
Any idea why I'm getting this error on Windows XP but not on Ubuntu Linux 9.04?
看起来screen.updater
是Updater(multiprocessing.Process)
的实例( def ),如果有帮助的话.有问题的文件位于 http://bazaar.launchpad.net/~gasp-dev/gasp-core/main/annotate/head%3A/gasp/backend.py
It looks like screen.updater
is an instance of Updater(multiprocessing.Process)
(def), if that helps. The file in question is at http://bazaar.launchpad.net/~gasp-dev/gasp-core/main/annotate/head%3A/gasp/backend.py
推荐答案
您的Updater
类具有成员screen
,该成员本身具有成员process
,该成员接收multiprocessing.current_process()
的值.
Your Updater
class has a member screen
, which itself has a member process
which receives the value of multiprocessing.current_process()
.
当您调用updater.start()
时,它将尝试使更新程序腌制.这仅在Windows上发生,因为Linux使用fork()
而不是酸洗.但是,不能对当前进程对象进行腌制,并且会引发异常.
When you call updater.start()
, it tries to pickle the updater. This only happens on Windows because Linux uses fork()
instead of pickling. However, the current-process object cannot be pickled and the exception is raised.
要解决此问题,您可以删除process
成员.
To fix this, you can remove the process
member.
这篇关于multiprocessing.Process子类可在Linux上运行,但不适用于Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!