At Thursday 19/10/2006 00:01, [EMAIL PROTECTED] wrote:

> Consider using the asyncore module instead of threads.

I think that is a good point and I am considering using
asyncore/asynchat...  i'm a little confused as to how i can make this
model work.  There is no server communication without connection from
the client (me), which happens on intervals, not when data is available
on a socket or when the socket is available to be written, which is
always.  Basically i need to determine how to trigger the asynchat
process based on time.  in another application that i write, i'm the
server and the chat process happens every time the client wakes
up...easy and perfect for asyncore

That is a solution i'd like to persue, but am having a hard time
getting my head around that as well.

You have to write your own dispatcher (inheriting from async_chat) as any other protocol. You can call asyncore.loop whith count=1 (or 10, but not None, so it returns after a few iterations) inside your *own* loop. Inside your loop, when time comes, call your_dispatcher.push(data) so the channel gets data to be sent. Override collect_incoming_data() to get the response. You can keep your pending requests in a priority queue (sorted by time) and check the current time against the top element's time.

Maybe you could successfully implement your application using threads - if none uses global variables, and no thread waits for another, it may be safe. But I prefer to avoid threads whenever possible, at least because debugging the application becomes harder.


--
Gabriel Genellina
Softlab SRL

        
        
                
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to