Re: [Python-3000] iostack and sock2

2006-06-06 Thread Greg Ewing
Jason Lunz wrote: > I imagine if one were going to do this, that would be hidden in the > stdlib. Having it in libc would be okay. The important thing is that the implementation should allow your handlers to get called even if some library call is blocked and not being cooperative. -- Greg _

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Josiah Carlson
"Giovanni Bajo" <[EMAIL PROTECTED]> wrote: > tomer filiba <[EMAIL PROTECTED]> wrote: > > >> 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

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Giovanni Bajo
tomer filiba <[EMAIL PROTECTED]> wrote: >> 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. Might be FUD o

Re: [Python-3000] iostack and sock2

2006-06-06 Thread tomer filiba
> 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

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Giovanni Bajo
> 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 interrupt

Re: [Python-3000] iostack and sock2

2006-06-06 Thread tomer filiba
WaitForMultipleObjects doesnt work on sockets of files... 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 sim

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Josiah Carlson
Greg Ewing <[EMAIL PROTECTED]> wrote: > > Ronald Oussoren wrote: > > > I'm slighly worried about this thread. Async I/O and "read exactly N > > bytes" don't really match up. I don't know about the other mechanisms, > > but at least with select and poll when the system says you can read > >

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Jason Lunz
On Wed, Jun 07, 2006 at 01:20:02AM +1200, Greg Ewing wrote: > It's not quite the same thing, anyway. What I had in mind was > attaching the handler itself directly to the file descriptor, rather > than going through a signal number. That way, different piece of code > can use the mechanism independ

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Greg Ewing
Marcin 'Qrczak' Kowalczyk wrote: > Greg Ewing <[EMAIL PROTECTED]> writes: >> f.read(0, num_bytes) # current read() behaviour > > Current read() reads at least 1 byte. Except if EOF is reached before getting any bytes. In that case, if min_bytes is 0, the call simply returns 0 bytes.

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Greg Ewing
Ronald Oussoren wrote: > I'm slighly worried about this thread. Async I/O and "read exactly N > bytes" don't really match up. I don't know about the other mechanisms, > but at least with select and poll when the system says you can read > from a file descriptor you're only guaranteed that on

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Greg Ewing
Jason Lunz wrote: > [EMAIL PROTECTED] said: > > > Sort of like being able to define signal handlers > > for file descriptors instead of having a small, fixed number of > > signals.) > > That's supported on linux, but I don't > know how portable it is. See F_SETSIG in fcntl(2), and sigaction(2).

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Marcin 'Qrczak' Kowalczyk
Greg Ewing <[EMAIL PROTECTED]> writes: > The two variations we're considering would then be special > cases of this: > >f.read(0, num_bytes) # current read() behaviour > >f.read(num_bytes, num_bytes) # record-oriented read() behaviour Current read() reads at least 1 byte. --

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Ronald Oussoren
On 6-jun-2006, at 11:51, Nick Coghlan wrote: > Greg Ewing wrote: >> tomer filiba wrote: >> >>> okay, i give up on read(n) returning n bytes. >> >> An idea I had about this some time ago was that read() >> could be callable with two arguments: >> >>f.read(min_bytes, max_bytes) >> >> The two va

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Nick Coghlan
Greg Ewing wrote: > tomer filiba wrote: > >> yes, but +=/-= can be overriden to provide "efficient seeking". and, just >> thought about it: just like negative indexes of sequences, negative positions >> should be relative to the end of the stream. for example: >> >> f.position = 4 # absolute -

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Nick Coghlan
Greg Ewing wrote: > tomer filiba wrote: > >> okay, i give up on read(n) returning n bytes. > > An idea I had about this some time ago was that read() > could be callable with two arguments: > >f.read(min_bytes, max_bytes) > > The two variations we're considering would then be special > case

Re: [Python-3000] iostack and sock2

2006-06-06 Thread Giovanni Bajo
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 time

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Jason Lunz
[EMAIL PROTECTED] said: > (BTW, I actually think this sort of functionality should be part of > the OS kernel, with event-driven programs and libraries being so > important nowadays. Sort of like being able to define signal handlers > for file descriptors instead of having a small, fixed number of

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Greg Ewing
tomer filiba wrote: > yes, but +=/-= can be overriden to provide "efficient seeking". and, just > thought about it: just like negative indexes of sequences, negative positions > should be relative to the end of the stream. for example: > > f.position = 4 # absolute -- seek(4, "start") > f.pos

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Greg Ewing
tomer filiba wrote: > okay, i give up on read(n) returning n bytes. An idea I had about this some time ago was that read() could be callable with two arguments: f.read(min_bytes, max_bytes) The two variations we're considering would then be special cases of this: f.read(0, num_bytes)

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Greg Ewing
tomer filiba wrote: > I wrote: > > My current opinion on select-like functionality is > > that you shouldn't need to import a module for it at > > all. Rather, you should be able to attach a callback > > directly to a stream. Then there just needs to be > > a wait_for_something_to_happen() fun

Re: [Python-3000] iostack and sock2

2006-06-05 Thread tomer filiba
> I don't believe it would "[destroy] the very foundations of python" > (unicode is not the very foundation of Python, and it wouldn't destroy > unicode, only change its comparison semantics), but I do believe it > "[lacks] a proper rationale" no, it would break the basic rules of comparisson. all

Re: [Python-3000] iostack and sock2

2006-06-05 Thread tomer filiba
hey > 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

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Josiah Carlson
"tomer filiba" <[EMAIL PROTECTED]> wrote: > > > > well, it's too hard to design for a nonexisting module. select is all > > > there > > > is that's platform independent. > > > > It is /relatively/ platform independent. > > if it runs on windows, linux, *bsd, solaris, it's virtually platform > i

Re: [Python-3000] iostack and sock2

2006-06-05 Thread Giovanni Bajo
tomer filiba wrote: > some time ago i wrote this huge post about stackable IO and the > need for a new socket module. i've made some progress with > those, and i'd like to receive feedback. > > * a working alpha version of the new socket module (sock2) is > available for testing and tweaking with

Re: [Python-3000] iostack and sock2

2006-06-05 Thread tomer filiba
> > well, it's too hard to design for a nonexisting module. select is all there > > is that's platform independent. > > It is /relatively/ platform independent. if it runs on windows, linux, *bsd, solaris, it's virtually platform independent. i don't consider the nokia N60 or whatever the name was

Re: [Python-3000] iostack and sock2

2006-06-05 Thread tomer filiba
> I'm -1 on having multiple kinds of read methods which> are available only on some kinds of streams. The> basic interface of a stream should be dirt simple. it's a convenience method. instead of doing it yourself everytime,readavail() returns all the available data in the socket's buffers.the basi

Re: [Python-3000] iostack and sock2

2006-06-04 Thread Greg Ewing
tomer filiba wrote: > NetworkStreams have a readavail() method, which reads all the available > in-queue data, as well as a may_read and a may_write properties I'm -1 on having multiple kinds of read methods which are available only on some kinds of streams. The basic interface of a stream should

Re: [Python-3000] iostack and sock2

2006-06-04 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: [snip] > Any operations that may touch the filesystem or network shouldn't be > properties - attribute access should never raise IOError (this is a guideline > that came out of the Path discussion). (e.g. the 'position' property is > probably a bad idea,

Re: [Python-3000] iostack and sock2

2006-06-04 Thread Josiah Carlson
"tomer filiba" <[EMAIL PROTECTED]> wrote: [snip] > > - interaction with (replacement of?) the select module > > well, it's too hard to design for a nonexisting module. select is all there > is that's platform independent. It is /relatively/ platform independent. > random idea: > * select is vir

Re: [Python-3000] iostack and sock2

2006-06-04 Thread tomer filiba
you certainly have good points there. i'll start with the easy ones: >Some things that don't appear to have been considered in the iostack design yet: > - non-blocking IO and timeouts (e.g. on NetworkStreams) NetworkStreams have a readavail() method, which reads all the available in-queue data, a

Re: [Python-3000] iostack and sock2

2006-06-03 Thread Nick Coghlan
tomer filiba wrote: > hi all > > some time ago i wrote this huge post about stackable IO and the > need for a new socket module. i've made some progress with > those, and i'd like to receive feedback. > > * a working alpha version of the new socket module (sock2) is > available for testing and tw

[Python-3000] iostack and sock2

2006-06-03 Thread tomer filiba
hi all some time ago i wrote this huge post about stackable IO and the need for a new socket module. i've made some progress with those, and i'd like to receive feedback. * a working alpha version of the new socket module (sock2) is available for testing and tweaking with at http://sebulba.wikisp