1

Python 2.7.3:

Create the simplest possible pyprocessing file and save it as foo.py:

from pyprocessing import *

def setup():
    size(100,100)

def draw():
    rect(10,10,10,10)

run()

Now in python:

>>> execfile('foo.py')

The file runs as expected. Close the pyprocessing window to return to the prompt and type:

>>> execfile('foo.py')

and you're greeted with:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "foo.py", line 9, in <module>
    run()
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/__init__.py", line 417, in run
    __main__.setup()
  File "foo.py", line 4, in setup
    size(100,100)
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/__init__.py", line 335, in size
    config=canvas.config, caption=caption, visible = isVisible)
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/flippolicy.py", line 142, in __init__
    super(BackupWindow, self).__init__(*args, **keyargs)
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 474, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/__init__.py", line 690, in __init__
    self.set_visible(True)
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 878, in set_visible
    self._map()
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/xlib/__init__.py", line 710, in _map
    self.dispatch_event('on_resize', self._width, self._height)
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/window/__init__.py", line 1219, in dispatch_event
    EventDispatcher.dispatch_event(self, *args)
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/event.py", line 352, in dispatch_event
    event_type, args, getattr(self, event_type))
  File "/usr/local/lib/python2.7/dist-packages/pyglet-1.1.4-py2.7.egg/pyglet/event.py", line 349, in dispatch_event
    return getattr(self, event_type)(*args)
  File "/usr/local/lib/python2.7/dist-packages/pyprocessing-0.1.3.22-py2.7.egg/pyprocessing/flippolicy.py", line 168, in on_resize
    super (FBOWindow, self).on_resize(w,h)
TypeError: super(type, obj): obj must be an instance or subtype of type

What is happening here? Is this a bug are am I using pyprocessing wrong?

EdChum
  • 376,765
  • 198
  • 813
  • 562
LondonRob
  • 73,083
  • 37
  • 144
  • 201
  • hi, see this answer http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell – archetipo Apr 18 '14 at 13:33
  • @archetipo: could you explain how that's relevant to this question? – LondonRob Apr 18 '14 at 13:36
  • because is not a good way to running this type of script , if you try to run this script with subprocess , you receive the same error? for definition pyprocessing is built upon openGL and pyglet ,and this require a dedicated process to make it stable. – archetipo Apr 18 '14 at 13:44
  • 1
    `call([sys.executable, 'foo.py'])` works fine. Do you want to write this up as a solution, and I'll accept it? – LondonRob Apr 18 '14 at 15:21

1 Answers1

1

This works as subprocess spawns a separate process each time:

from subprocess import call 
call([sys.executable, 'foo.py'])

See this SO question for a fuller discussion of subprocess.call.

Community
  • 1
  • 1
archetipo
  • 579
  • 4
  • 10
  • read the comments, my up vote is not a thank you, but a good, because the solution was reasoned together ... in this question, the solution is the approach not the method used .. – archetipo Apr 18 '14 at 18:14