Sftp type error #49363

Robey Pointer robey at lag.net
Fri Jun 16 01:19:10 BST 2006


On 14 Jun 2006, at 19:43, John Arbash Meinel wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robey Pointer wrote:
>>
>
> ...
>
>> +    def run(self):
>> +        while True:
>> +            readable, _, _ = select.select([self._socket], [],  
>> [], 0.1)
>> +            if self._stop_event.isSet():
>> +                return
>> +            if len(readable) == 0:
>> +                continue
>> +            try:
>> +                s, _ = self._socket.accept()
>> +                # because the loopback socket is inline, and  
>> transports are
>> +                # never explicitly closed, best to launch a new  
>> thread.
>> +                threading.Thread(target=self._callback, args= 
>> (s,)).start()
>> +            except socket.error, x:
>> +                pass #Ignore socket errors
>> +            except Exception, x:
>> +                # probably a failed test
>> +                sys.excepthook(*sys.exc_info())
>> +                warning('Exception from within unit test server  
>> thread: %r' % x)
>
> I personally don't like the look of the '_' variable names, though I
> understand it is because you are ignoring the return value.
> Perhaps 'dummy', though I wouldn't block on it.

I'm agnostic and happy to change them to 'dummy'.  I picked up the  
'_' habit from some other python code I saw once.  Ammended patch  
attached.


> Is select.select() portable across platforms?
> Any reason not to use asyncore instead?

It should be (on sockets only).  Asyncore would probably work too.   
The point of the select() here is not to poll multiple sockets, but  
to do an equivalent to socket.accept(timeout).  Gawd, I've written  
this kind of code so many times that I feel older just looking at it  
again.  Anyway, the timeout is so that we can simultaneously scan for  
an incoming accept() *and* the stop_event.

robey


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: listener-patch.txt
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20060615/05eea8d7/attachment.txt 


More information about the bazaar mailing list