you are right for -2-
Actually, in my real code, gap is modified by on_mouse_press or
on_key_press (only by the other thread).
That was juste for the sample.
I should have put a lock() to be cleaner.


On Feb 9, 9:33 pm, claudio canepa <[email protected]> wrote:
> On Thu, Feb 9, 2012 at 6:22 AM, Philippe <[email protected]> wrote:
> > Hello again ..
>
> > I have an issue with the update of my sprites.
> > I pasted a small sample that reproduce my problem here:
> >http://pastebin.com/KrajS6RX
>
> > I set 3 ways of changing the mask of my_sprite.
>
> > 1- user can click on the sripte, it reduce the mask width => it works
> > well
>
> > 2- user can press a key on the Layer, the layer use a
> > pyglet.event.EventDispatcher to push an event, my_sprite receive it =>
> > it works well too !
>
> > 3- I go a thread, in my pyglet.event.EventDispatcher that push an
> > event every 5s. my_sprite receive it, but does not update itself in
> > the window.
> > I tried to add the self.draw() instruction, but got an error:
> > GLException: invalid operation
>
> > Any idea ?
> > If I move the mouse over the window, I got clean refresh, even for
> > -3-. I would like to have the same, but without moving the mouse
> > around!
>
> > thanks
>
> I don't really know about threads, but
>
> 1. I remember some comments in the line 'calls to openGL must be done from
> the same thread that acquired the openGL context'. So I don't expect that
> ultimately calling to .draw from other thread can work
>
> 2. Maybe is an artifact from your sample, but you are modifying self.gap
> from two different threads. That will explode at some time, when one thread
> is amidst of changing gap, the other thread kicks in and also tries to
> change gap
>
> 3. Usually code that can be called from multiple threads is explicitly
> announced as multithread safe ; I don't remember any such comments in the
> pyglet event docs.
>
> 4. Perhaps some of the posts here:
>
> http://search.gmane.org/search.php?group=gmane.comp.python.pyglet.use...
>
> may help you
>
> 5. Out of curiosity, what is your real use case for threading with pyglet ?
> Are you sure you are not killing flies with missiles ?
>
> --
> claudio

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en.

Reply via email to