> You can use WSAAsyncSelect to activate message notification for socket events, > and then wait with MsgWaitForMultipleObjects.
i remember reading in the winsock manual that these two methods are slower, and not suitable for servers. > It *is* possible to have a single point of event dispatching under Windows > too, > and it is even possible to have it wrapped portably as Qt did. This is why I > do > expect Python to be able to handle this kind of things i agree, but it needs much more thinking and research, and i will look into it. but i'm not sure it should be part of the iostack. this kind of sync/async io needs more thought anyway. -tomer On 6/6/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > > On 6/6/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > >> tomer filiba <[EMAIL PROTECTED]> wrote: > >> > >>>> One thing I would like to raise is the issue of KeyboardInterrupt. > >>>> I find very inconvenient that a normal application doing a very > >>>> simple blocking read from a socket can't be interrupted by a CTRL+C > >>>> sequence. Usually, what I do is to setup a timeout on the sockets > >>>> (eg. 0.4 seconds) and then simply retry if the data has not arrived > >>>> yet. But this changes the code from: > >>> > >>> from my experience with linux and solaris, this CTRL+C problem only > >>> happens on windows machines. but then again, windows can't select() > >>> on anything but sockets, so there's not gonna be a generic solution. > >> > >> Windows has WaitForMultipleObjects() which can be used to multiplex > >> between sockets and other handles. > >> > > WaitForMultipleObjects doesnt work on sockets of files... > > You can use WSAAsyncSelect to activate message notification for socket events, > and then wait with MsgWaitForMultipleObjects. > > Qt has a very good portable "reactor" implementation (QEventLoop in Qt3, could > be renamed in Qt4) where you can register various events, including socket > notifications and of course normal window messages. The implementation in Qt4 > is GPL so you can have a look (src/corelib/kernel/qeventdispatcher_win.cpp). > > It *is* possible to have a single point of event dispatching under Windows > too, > and it is even possible to have it wrapped portably as Qt did. This is why I > do > expect Python to be able to handle this kind of things. Whatever portable > poll/epoll/kqueue-kind of thing we end up with Py3k, it should use a similar > technique under Windows to make sure normal messages are still processed. You > really don't want to wait on sockets only and ignore Window messages > altogether > anyway. > > Giovanni Bajo > > _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
