non-blocking sockets and generators
Gary Stephenson
garys at ihug.com.au
Sat May 24 06:39:10 EDT 2003
I'm playing around with combining non-blocking sockets with generators -
which is probably really stupid 'coz I don't know terribly much about either
but, hey .. I _am_ learning....
Anyway, I suspect my first question has nothing to do with non-blocking
sockets _or_ generators, albeit that both appear in the code. Why does this
:
def socketAccept( self, s ) :
while True :
try :
( sock, addr ) = s.accept()
except :
yield None
self.addThread( self.createThread( sock, addr ) )
yield the following error ? (running under Pythonwin) :
self.addThread( self.createThread( sock, addr ) )
UnboundLocalError: local variable 'sock' referenced before assignment
Also, I'd like to be a touch more specific ;-) in the except clause, but I
can't seem to figure out the appropriate exception class to use. The socket
docs talk about non-blocking sockets raising
"a 'error' exception", but when I tried to use "except error : " I got
NameError: global name 'error' is not defined
What exception class (if any) should be used to catch the non-blocking
socket's exception?
many tias,
gary
More information about the Python-list
mailing list