Re: select.select()

2013-11-22 Thread Chris Angelico
On Sat, Nov 23, 2013 at 1:15 PM, Roy Smith wrote: > (*) I'm not sure if real MUDs are programmed this way, but it's a > plausible architecture. For simplicity sake, I'm assuming a > single-threaded server. Yeah, they certainly can. That's effectively the way that I programmed the MUD kernel that

Re: select.select()

2013-11-22 Thread Bhanu Karthik
On Friday, 22 November 2013 18:15:10 UTC-8, Roy Smith wrote: > In article , > > Bhanu Karthik wrote: > > > > > please help me.. what does the following line do? > > > > > > read_sockets,write_sockets,error_sockets = > > > select.select

Re: select.select()

2013-11-22 Thread Bhanu Karthik
On Friday, 22 November 2013 18:29:12 UTC-8, Steven D'Aprano wrote: > On Fri, 22 Nov 2013 17:42:07 -0800, Bhanu Karthik wrote: > > > > > please help me.. what does the following line do? > > > > > > read_sockets,write_sockets,error_socke

Re: select.select()

2013-11-22 Thread Steven D'Aprano
On Fri, 22 Nov 2013 17:42:07 -0800, Bhanu Karthik wrote: > please help me.. what does the following line do? > > read_sockets,write_sockets,error_sockets = > select.select(CONNECTION_LIST,[],[]) The select.select function takes three arguments (plus an optional fourth): s

Re: select.select()

2013-11-22 Thread Roy Smith
In article , Bhanu Karthik wrote: > please help me.. what does the following line do? > > read_sockets,write_sockets,error_sockets = > select.select(CONNECTION_LIST,[],[]) This is a little tricky. First,read the docs at http://docs.python.org/2/library/select.html. Ther

select.select()

2013-11-22 Thread Bhanu Karthik
please help me.. what does the following line do? read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[]) -- https://mail.python.org/mailman/listinfo/python-list

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-09 Thread Paul Kölle
Am 09.05.2010 11:59, schrieb Lawrence D'Oliveiro: In message, exar...@twistedmatrix.com wrote: On 07:48 am, l...@geek-central.gen.new_zealand wrote: In message, exar...@twistedmatrix.com wrote: This is a good example of why it's a bad idea to use select on Windows. Instead, use WaitForMulti

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-09 Thread Lawrence D'Oliveiro
In message , exar...@twistedmatrix.com wrote: > On 07:48 am, l...@geek-central.gen.new_zealand wrote: > >>In message , >>exar...@twistedmatrix.com wrote: >> >>>This is a good example of why it's a bad idea to use select on >>>Windows. >>>Instead, use WaitForMultipleObjects. >> >>How are you suppo

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Giampaolo Rodolà
2010/5/8 Antoine Pitrou : > On Sat, 8 May 2010 13:47:53 +0200 > Giampaolo Rodolà wrote: >> >> Assuming loop() function does something like this: >> >>      ... >>      select.select(r, w, e, timeout) >>      scheduler()  # checks for scheduled calls to be

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread exarkun
) function does something like this: ... select.select(r, w, e, timeout) scheduler() # checks for scheduled calls to be fired ... ...imagine a case where there's a connection (aka a dispatcher instance) which does not receive or send any data *and* a scheduled call which is suppo

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread exarkun
On 07:48 am, l...@geek-central.gen.new_zealand wrote: In message , exar...@twistedmatrix.com wrote: This is a good example of why it's a bad idea to use select on Windows. Instead, use WaitForMultipleObjects. How are you supposed to write portable code, then? With WaitForMultipleObjects on

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Antoine Pitrou
On Sat, 8 May 2010 13:47:53 +0200 Giampaolo Rodolà wrote: > > Assuming loop() function does something like this: > > ... > select.select(r, w, e, timeout) > scheduler() # checks for scheduled calls to be fired > ... > > ...imagine a case where

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Giampaolo Rodolà
> Why? Assuming loop() function does something like this: ... select.select(r, w, e, timeout) scheduler() # checks for scheduled calls to be fired ... ...imagine a case where there's a connection (aka a dispatcher instance) which does not receive or send any data

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-08 Thread Lawrence D'Oliveiro
In message , exar...@twistedmatrix.com wrote: > This is a good example of why it's a bad idea to use select on Windows. > Instead, use WaitForMultipleObjects. How are you supposed to write portable code, then? -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread exarkun
On 7 May, 07:25 pm, p.f.mo...@gmail.com wrote: On 7 May 2010 15:36, Giampaolo Rodol� wrote: You can easily avoid this by setting a lower timeout when calling asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 secs). Thanks, that's what I was considering. This is a good

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 21:55:15 +0200, Giampaolo Rodolà a écrit : > Of course, but 30 seconds look a little bit too much to me, also because > (I might be wrong here) I noticed that a smaller timeout seems to result > in better performances. That's probably bogus. > Plus, if scheduled callbacks are

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Giampaolo Rodolà
2010/5/7 Antoine Pitrou : > Le Fri, 07 May 2010 16:36:44 +0200, Giampaolo Rodolà a écrit : >> You can easily avoid this by setting a lower timeout when calling >> asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 >> secs). >> Actually there's no reason for asyncore to have suc

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Paul Moore
On 7 May 2010 15:36, Giampaolo Rodolà wrote: > You can easily avoid this by setting a lower timeout when calling > asyncore.loop(), like 1 second or less (for example, Twisted uses > 0.001 secs). Thanks, that's what I was considering. > Actually there's no reason for asyncore to have such a high

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Antoine Pitrou
Le Fri, 07 May 2010 16:36:44 +0200, Giampaolo Rodolà a écrit : > You can easily avoid this by setting a lower timeout when calling > asyncore.loop(), like 1 second or less (for example, Twisted uses 0.001 > secs). > Actually there's no reason for asyncore to have such a high default > timeout (30 s

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Giampaolo Rodolà
acker. --- Giampaolo http://code.google.com/p/pyftpdlib http://code.google.com/p/psutil 2010/5/6 Paul Moore : > >From a quick experiment, it seems that select.select with a timeout > doesn't react to a keyboard interrupt until the timeout expires. > Specifically, if I do > > s = socket

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-07 Thread Paul Moore
On 6 May, 20:58, Thomas Heller wrote: > If you look at the source code for time.sleep(), which CAN be interrupted > by pressing Ctrl-C, you will find that it is carefully programmed to be > interruptible (sp?).  Which is not the case for select.select(), obviously. Thanks - given this,

Re: Windows - select.select, timeout and KeyboardInterrupt

2010-05-06 Thread Thomas Heller
Paul Moore schrieb: >>From a quick experiment, it seems that select.select with a timeout > doesn't react to a keyboard interrupt until the timeout expires. > Specifically, if I do > > s = socket.socket() > select.select([s], [], [], 30) > > and then press Ctrl-C,

Windows - select.select, timeout and KeyboardInterrupt

2010-05-06 Thread Paul Moore
>From a quick experiment, it seems that select.select with a timeout doesn't react to a keyboard interrupt until the timeout expires. Specifically, if I do s = socket.socket() select.select([s], [], [], 30) and then press Ctrl-C, Python waits for the 30 seconds before raising KeyboardI

Re: select.select and socket.setblocking

2009-01-03 Thread Roy Smith
Bryan Olson wrote: > There are cases where a socket can select() as readable, but not be > readable by the time of a following recv() or accept() call. All such > cases with which I'm familiar call for a non-blocking socket. I used to believe that if select() said data was ready for reading, a

Re: select.select and socket.setblocking

2009-01-03 Thread Saju Pillai
Bryan Olson wrote: > >Where does this come up? Suppose that to take advantage of multi-core >processors, our server runs as four processes, each with a single thread >that responds to events via select(). Clients all connect to the same >server port, so the socket listening on that port is sh

Re: select.select and socket.setblocking

2009-01-03 Thread Bryan Olson
Laszlo Nagy wrote: [...] I have read the socket programming howto ( http://docs.python.org/howto/sockets.html#sockets ) but it does not explain how a blocking socket + select is different from a non blocking socket + select. Is there any difference? There is, but it may not effect you. There ar

Re: select.select and socket.setblocking

2009-01-01 Thread Francesco Bochicchio
Can you post an example program that exhibits the behavior you describe? I was forgetting about the MSG_WAITALL flag ... When I started programming with sockets, it was on a platform (IIRC Solaris) that by default behaved like MSG_WAITALL was set by default (actually, I don't remember it be

Re: select.select and socket.setblocking

2008-12-31 Thread Hendrik van Rooyen
"Francesco Bochicchio" wrote: > but then, IIRC TCP guarantees that the packet is fully received by > hand-shaking at transport level between sender and receiver. Ad once the > packet is fully in the receiver buffer, why should recv choose to give > back to the application only a piece of it? T

Re: select.select and socket.setblocking

2008-12-31 Thread Francesco Bochicchio
Saju Pillai ha scritto: On Dec 31, 7:48 pm, Francesco Bochicchio wrote: Is this correct ? IIRC even in blocking mode recv() can return with less bytes than requested, unless the MSG_WAITALL flag is supplied. Blocking mode only guarantees that recv() will wait for a message if none is available

Re: select.select and socket.setblocking

2008-12-31 Thread Scott David Daniels
Jean-Paul Calderone wrote: ... On a LAN, it's likely that you'll generally get the exact number of bytes which the sender passed to one call of send (until the sender starts to pass really huge strings to send, then it'll get split up) just because the network has lots of capacity compared to the

Re: select.select and socket.setblocking

2008-12-31 Thread Grant Edwards
On 2008-12-31, Francesco Bochicchio wrote: > Grant Edwards ha scritto: >> On 2008-12-30, Francesco Bochicchio wrote: >> >>> 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in >>> select between blocking and non-blocking mode. The difference is in the >>> recv (again, assumin

Re: select.select and socket.setblocking

2008-12-31 Thread Jean-Paul Calderone
On Wed, 31 Dec 2008 15:48:50 +0100, Francesco Bochicchio wrote: < ... > Uhm. In my experience, with TCP protocol recv only returned less than the required bytes if the remote end disconnects. I always check the What if the sending end actually sent less than you asked for ? -srp In blocki

Re: select.select and socket.setblocking

2008-12-31 Thread Karen Tracey
On Wed, Dec 31, 2008 at 5:39 AM, Francesco Bochicchio wrote: > Francesco Bochicchio ha scritto: > >> >>> No, in blocking mode it will wait to receive _some_ data (1 or >>> more bytes). The "requested" amount is strictly an upper >>> limit: recv won't return more than the requested number of >>> b

Re: select.select and socket.setblocking

2008-12-31 Thread Saju Pillai
On Dec 31, 7:48 pm, Francesco Bochicchio wrote: > < ... > > > >> Uhm. In my experience, with TCP protocol recv only returned less than > >> the required bytes if the remote end disconnects. I always check the > > > What if the sending end actually sent less than you asked for ? > > > -srp > > In b

Re: select.select and socket.setblocking

2008-12-31 Thread Francesco Bochicchio
< ... > Uhm. In my experience, with TCP protocol recv only returned less than the required bytes if the remote end disconnects. I always check the What if the sending end actually sent less than you asked for ? -srp In blocking mode and with TCP protocol, the recv waits until more bytes a

Re: select.select and socket.setblocking

2008-12-31 Thread Saju Pillai
On Dec 31, 2:01 pm, Francesco Bochicchio wrote: > Grant Edwards ha scritto: > > > On 2008-12-30, Francesco Bochicchio wrote: > > >> 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in > >> select between blocking and non-blocking mode. The difference is in the > >> recv (again,

Re: select.select and socket.setblocking

2008-12-31 Thread Francesco Bochicchio
Francesco Bochicchio ha scritto: No, in blocking mode it will wait to receive _some_ data (1 or more bytes). The "requested" amount is strictly an upper limit: recv won't return more than the requested number of bytes, but it might return less. Uhm. In my experience, with TCP protocol recv o

Re: select.select and socket.setblocking

2008-12-31 Thread Francesco Bochicchio
Jean-Paul Calderone ha scritto: On Tue, 30 Dec 2008 19:19:08 +0100, Francesco Bochicchio wrote: [snip] If you are interested in socket errors, you should also fill the third 'fd-set' in the select call, and after select returns check that fd is not in it anymore: ready = select.s

Re: select.select and socket.setblocking

2008-12-31 Thread Francesco Bochicchio
Grant Edwards ha scritto: On 2008-12-30, Francesco Bochicchio wrote: 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in select between blocking and non-blocking mode. The difference is in the recv (again, assuming that you use TCP as protocol, that is AF_INET, SOCK_STREAM)

Re: select.select and socket.setblocking

2008-12-30 Thread Jean-Paul Calderone
On Tue, 30 Dec 2008 15:55:51 -0500, Jean-Paul Calderone wrote: On Tue, 30 Dec 2008 14:41:17 -0600, Grant Edwards wrote: On 2008-12-30, Francesco Bochicchio wrote: 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in select between blocking and non-blocking mode. The differ

Re: select.select and socket.setblocking

2008-12-30 Thread Jean-Paul Calderone
On Tue, 30 Dec 2008 14:41:17 -0600, Grant Edwards wrote: On 2008-12-30, Francesco Bochicchio wrote: 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in select between blocking and non-blocking mode. The difference is in the recv (again, assuming that you use TCP as protocol

Re: select.select and socket.setblocking

2008-12-30 Thread Grant Edwards
On 2008-12-30, Francesco Bochicchio wrote: > 3. AFAIK (sorry, I feel acronym-ly today ;), there is no difference in > select between blocking and non-blocking mode. The difference is in the > recv (again, assuming that you use TCP as protocol, that is AF_INET, > SOCK_STREAM), which in the block

Re: select.select and socket.setblocking

2008-12-30 Thread Jean-Paul Calderone
On Tue, 30 Dec 2008 19:19:08 +0100, Francesco Bochicchio wrote: [snip] If you are interested in socket errors, you should also fill the third 'fd-set' in the select call, and after select returns check that fd is not in it anymore: ready = select.select( [fd],[], [fd] ) if fd

Re: select.select and socket.setblocking

2008-12-30 Thread Francesco Bochicchio
sSet(): remaining = size - len(res) if remaining<=0: break # Give one second for an incoming connection so we can stop the # server in seconds when needed ready = select.select([fd], [], [], 1) if fd in ready[0]:

Re: select.select and socket.setblocking

2008-12-30 Thread Steve Holden
t self.stop_requested.isSet(): >remaining = size - len(res) >if remaining<=0: >break ># Give one second for an incoming connection so we can stop the ># server in seconds when needed >ready

select.select and socket.setblocking

2008-12-30 Thread Laszlo Nagy
= size - len(res) if remaining<=0: break # Give one second for an incoming connection so we can stop the # server in seconds when needed ready = select.select([fd], [], [], 1) if fd in ready[0]: data = self.socket

Issue with select.select() and missing data

2008-03-23 Thread nnp
Hi guys, I have an issue when using select.select(). I have an application that creates sockets then sends data on them. These sockets are then passed off to a listener which uses select.select() to detect any responses. For some reason every socket can only receive one response before my

Re: select.select() on windows

2005-10-27 Thread Maksim Kasimov
yes, i missed, sorry Dennis Lee Bieber wrote: > On Wed, 26 Oct 2005 11:29:17 +0300, Maksim Kasimov > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >>you have to use non-block readining. >> >>http://docs.python.org/lib/module-select.html: >>A time-out value of zero specifi

Re: select.select() on windows

2005-10-26 Thread Ben Sizer
socket, i have stdout. > > Any suggestions on how to do a timeout like select.select with stdout? I am not too familiar with any asynchronous I/O facilities in Python beyond select, so in your situation I would use the threading module, with the blocking read in one thread and your time-out i

Re: select.select() on windows

2005-10-26 Thread Maksim Kasimov
waiting for more > bytes. So what I would like is to timeout...and select.selec() seems > to be what I need. Except I don't have a socket, i have stdout. > > Any suggestions on how to do a timeout like select.select with stdout? > > Thanks > -- Best regards, Ma

select.select() on windows

2005-10-25 Thread jas
ons on how to do a timeout like select.select with stdout? Thanks -- http://mail.python.org/mailman/listinfo/python-list