Thanks, I'm getting the same. As you say, it does nothing. Now, I add something to be done before wx.CallAfter:
wx.App.__init__(self)
print 'do'
wx.CallAfter(self.StartProcessing)
and the Mainloop at the end:
if __name__ == "__main__":
app = App()
app.MainLoop()
And now, I get the same error on the console + a wxPython stdout/stderr window with this (long) traceback:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 14669, in <lambda>
lambda event: event.callable(*event.args, **event.kw) )
File "with_wx_andrea.py", line 17, in StartProcessing
p.start()
File "C:\Python27\Lib\multiprocessing\process.py", line 130, in start
self._popen = Popen(self)
File "C:\Python27\Lib\multiprocessing\forking.py", line 271, in __init__
dump(process_obj, to_child, HIGHEST_PROTOCOL)
File "C:\Python27\Lib\multiprocessing\forking.py", line 193, in dump
ForkingPickler(file, protocol).dump(obj)
File "C:\Python27\Lib\pickle.py", line 224, in dump
self.save(obj)
File "C:\Python27\Lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\Lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python27\Lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\Lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\Lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\Lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\Lib\multiprocessing\forking.py", line 66, in dispatcher
self.save_reduce(obj=obj, *rv)
File "C:\Python27\Lib\pickle.py", line 401, in save_reduce
save(args)
File "C:\Python27\Lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\Lib\pickle.py", line 548, in save_tuple
save(element)
File "C:\Python27\Lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\Lib\pickle.py", line 419, in save_reduce
save(state)
File "C:\Python27\Lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\Lib\pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "C:\Python27\Lib\pickle.py", line 681, in _batch_setitems
save(v)
File "C:\Python27\Lib\pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "C:\Python27\Lib\pickle.py", line 396, in save_reduce
save(cls)
File "C:\Python27\Lib\pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "C:\Python27\Lib\pickle.py", line 748, in save_global
(obj, module, name))
pickle.PicklingError: Can't pickle <type 'PySwigObject'>: it's not found as __builtin__.PySwigObject
Raphael
···
On 5/8/2012 10:39 AM, Andrea Gavana wrote:
Hi,
On 8 May 2012 10:34, Raphael Mayoraz wrote:
Hello,
In my wx application, that is pretty complex, I'd like to use
multiprocessing to do some long running jobs that should be run in parallel.
Attached are 2 pieces of code.
- 'with_wx.py': is using wx, as I do to launch my application.
This fails with this traceback:
Traceback (most recent call last):
File "<string>", line 1, in<module>
File "C:\Python27\Lib\multiprocessing\forking.py", line 374, in main
self = load(from_parent)
File "C:\Python27\Lib\pickle.py", line 1378, in load
return Unpickler(file).load()
File "C:\Python27\Lib\pickle.py", line 858, in load
dispatch[key](self)
File "C:\Python27\Lib\pickle.py", line 880, in load_eof
raise EOFError
EOFError
- 'without wx.py': is the same code, but it doesn't use wx.
This works fine.
I understand there may be dome problems running multiprocessing within a wx
application, so what's the solution ?
Using Python 2.7.2 and wxPython 2.8.11
Try the attached modified sample, it works for me on Windows Vista 64
bit, wx 2.9.3 (I mean, it doesn't crash like your original sample,
although it does nothing by itself).
Andrea.