On Thu, Feb 9, 2012 at 6:20 PM, Philippe <[email protected]> wrote:

> Hello,
>
> In my threading.Thread(target=self.timed_event)...
> I simplified timed_event to get a small sample that reproduce my
> problem.
>
> But actually, inside timed_event, I have a UDP communication with some
> other software.
> That's why I need that thread. It's a simple communication that
> include a python Queue().
> In that thread, when there is something in the Queue, it will be
> pushed as a pyglet event for the Layers.
>
> That's the idea ! It works fine in other python software I made.
> In cocos, I do not know how to remove that thread. Is there some sort
> of "pyglet thread" available for that purpose ?
>
> My real timed_event function is more like:
> while self.running:
>    msg = self.my_queue.get()
>    self.dispatch_event('on_data_update_from_thread', msg)
>
>
If your
    self.dispatch_event('...')
is in the main thread that would look a lot better than in the sample.
And, queues from Queue seem to be thread-safe [1]

But some comments in the threads [2][3] suggest that maybe the pyglet
mainloop code should be changed

Probably the better would be to rewrite the sample code using a queue, with
the call to dispatch_event in the main thread, and maybe post at the pyglet
mail list


[1] http://www.ibm.com/developerworks/aix/library/au-threadingpython/
[2] http://thread.gmane.org/gmane.comp.python.pyglet.user/3
[3] http://thread.gmane.org/gmane.comp.python.pyglet.user/2120

--
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