Events and file polling in a C extension
Josiah Carlson
jcarlson at uci.edu
Sat Oct 23 18:32:26 EDT 2004
More information about the Python-list mailing list
Sat Oct 23 18:32:26 EDT 2004
- Previous message (by thread): Events and file polling in a C extension
- Next message (by thread): How to start a new thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Josiah Carlson <jcarlson at uci.edu> wrote: > I believe that most languages support event handling in one way or > another. Here is one way... > > def handle_event(event): > if event.typ == 'new_connection': > #handle a new connection > elif event.typ == ... > > Or, if you want to use something that already has much of this designed > and built for sockets, check out asyncore or asynchat. Use > asyncore.loop(timeout, 1) to poll the sockets every 1/100th of a second > or so, and you should be good. That is not to say that asyncore.loop(timeout, 1) will poll the sockets every 100th a second, just that you should make that call about every 1/100th a second (timeout of 0 would be a true poll). - Josiah
- Previous message (by thread): Events and file polling in a C extension
- Next message (by thread): How to start a new thread ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list