socket.error(35, "Operation would block")
so you need to catch it, e.g.,
try:
thisMessage = sock.read(1024)
except:
print "There wasn't anything to read"
SO, here is the diff file from the socketmodule distributed
with 1.0.3 to the socketmodule with setblocking added. Use it in good
health and let me know if this does not work somewhere.
---------%< snip %<------------------%< snip %<---------
55a56
> - s.setblocking(1 | 0) --> None
77a79
> #include <fcntl.h>
483a486
> /* s.setblocking(1 | 0) method */
484a488,509
> static object *
> sock_setblocking(s, args)
> sockobject *s;
> object *args;
> {
> int block;
> if (!getintarg(args, &block))
> return NULL;
> BGN_SAVE
> int delay_flag = fcntl (s->sock_fd, F_GETFL, 0);
> if (block)
> delay_flag &= (~O_NDELAY);
> else
> delay_flag |= O_NDELAY;
> fcntl (s->sock_fd, F_SETFL, delay_flag);
> END_SAVE
>
> INCREF(None);
> return None;
> }
>
>
803a829
> {"setblocking", (method)sock_setblocking},
-------> Tommy.
"I am who I am who I am. Well, who am I?" -- Dave Matthews