Bug#513315: Times out waiting for index to be rebuilt

2009-01-30 Thread Michael Vogt
On Wed, Jan 28, 2009 at 04:25:32AM -0800, Matt Kraai wrote:
 tag 513315 + patch
 thanks
 
 On Wed, Jan 28, 2009 at 12:04:33PM +, Enrico Zini wrote:
  Importing apt is what makes the problem reappear: apt seems to be
  changing the default timeout from None to 2.0: I'll reassign this bug
  to python-apt.
 
 Thanks for figuring out which package was causing the problem.
 
 python-apt is setting the default timeout so that it will time out if
 downloading a changelog takes too long.  The attached patch modifies
 it to change the default just as long as necessary.  It's racy, but I
 think it will work in this case.
 
 Once python-apt requires Python 2.6, it can use urllib2.urlopen's
 optional timeout parameter instead.
[..]

Thanks, this is part of my bzr tree and it will be part of the next
upload. 

Cheers,
 Michael



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#513315: Times out waiting for index to be rebuilt

2009-01-30 Thread Matt Kraai
On Fri, Jan 30, 2009 at 09:19:31PM +0100, Michael Vogt wrote:
 Thanks, this is part of my bzr tree and it will be part of the next
 upload. 

Great!  Do you know when this'll be?  I don't know how to build an
experimental chroot until this is fixed.

-- 
Matt http://ftbfs.org/



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#513315: Times out waiting for index to be rebuilt

2009-01-28 Thread Enrico Zini
On Tue, Jan 27, 2009 at 04:01:13PM -0800, Matt Kraai wrote:

 When I try to create an experimental pbuilder chroot using
  pbuilder --create --distribution experimental
 it fails with the following error message:
[...]
  Rebuilding Xapian index... 39% 
  Traceback (most recent call last):
File /usr/sbin/update-apt-xapian-index, line 527, in module
  childProgress.loop()
File /usr/sbin/update-apt-xapian-index, line 125, in loop
  msg = self.sock.recv(4096)
  socket.timeout: timed out
[...]
 I can't figure out why that exception is raised, however: according to
 the exception's documentation, it's raised if the timeout's been set
 via a call to settimeout, but there are no such calls in
 update-apt-xapian-index.

Indeed, according to the exception documentation, the default is None
(no timeout), but if I add this to the code, just after
self.sock.connect(XAPIANDBUPDATESOCK) in ClientProgress.__init__:

   print TIMEOUT, self.sock.gettimeout()

I get a nice 2.0.

This patch fixes the problem:

   diff --git a/update-apt-xapian-index b/update-apt-xapian-index
   index ad815f4..31ecad9 100755
   --- a/update-apt-xapian-index
   +++ b/update-apt-xapian-index
   @@ -116,6 +116,7 @@ class SilentProgress:
class ClientProgress:
def __init__(self, progress):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
   +self.sock.settimeout(None)
self.sock.connect(XAPIANDBUPDATESOCK)
self.progress = progress

I can reproduce the issue with this snippet:

   #!/usr/bin/python
   
   import apt, socket
   
   srv = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
   srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
   srv.bind(/tmp/foo.sock)
   srv.setblocking(False)
   srv.listen(5)
   
   sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
   sock.connect(/tmp/foo.sock)
   print sock.gettimeout()
   
   s1 = srv.accept()[0]
   s1.send(ciao)
   
   print sock.recv(4096)

Importing apt is what makes the problem reappear: apt seems to be
changing the default timeout from None to 2.0: I'll reassign this bug
to python-apt.


Ciao,

Enrico

-- 
GPG key: 1024D/797EBFAB 2000-12-05 Enrico Zini enr...@debian.org


signature.asc
Description: Digital signature


Bug#513315: Times out waiting for index to be rebuilt

2009-01-28 Thread Matt Kraai
tag 513315 + patch
thanks

On Wed, Jan 28, 2009 at 12:04:33PM +, Enrico Zini wrote:
 Importing apt is what makes the problem reappear: apt seems to be
 changing the default timeout from None to 2.0: I'll reassign this bug
 to python-apt.

Thanks for figuring out which package was causing the problem.

python-apt is setting the default timeout so that it will time out if
downloading a changelog takes too long.  The attached patch modifies
it to change the default just as long as necessary.  It's racy, but I
think it will work in this case.

Once python-apt requires Python 2.6, it can use urllib2.urlopen's
optional timeout parameter instead.

-- 
Matt http://ftbfs.org/
diff -ru python-apt-0.7.9~exp2~/apt/package.py python-apt-0.7.9~exp2/apt/package.py
--- python-apt-0.7.9~exp2~/apt/package.py	2009-01-28 04:11:24.0 -0800
+++ python-apt-0.7.9~exp2/apt/package.py	2009-01-28 04:17:38.0 -0800
@@ -32,10 +32,6 @@
 __all__ = 'BaseDependency', 'Dependency', 'Origin', 'Package', 'Record'
 
 
-# Set a timeout for the changelog download
-socket.setdefaulttimeout(2)
-
-
 def _(string):
 Return the translation of the string.
 return gettext.dgettext(python-apt, string)
@@ -600,7 +596,12 @@
 # Check if the download was canceled
 if cancel_lock and cancel_lock.isSet():
 return 
+# FIXME: Once Python 2.6 is required, the timeout can be set using
+# urllib2.urlopen's timeout parameter.
+timeout = socket.getdefaulttimeout()
+socket.setdefaulttimeout(2)
 changelog_file = urllib2.urlopen(uri)
+socket.setdefaulttimeout(timeout)
 # do only get the lines that are new
 changelog = 
 regexp = ^%s \((.*)\)(.*)$ % (re.escape(src_pkg))


Bug#513315: Times out waiting for index to be rebuilt

2009-01-27 Thread Matt Kraai
Package: apt-xapian-index
Version: 0.16

When I try to create an experimental pbuilder chroot using

 pbuilder --create --distribution experimental

it fails with the following error message:

 Setting up apt-xapian-index (0.16) ...
 apt-xapian-index: Building new index in background...
 Setting up libsigc++-2.0-0c2a (2.2.2-1) ...
 Setting up libcwidget3 (0.5.12-3) ...
 Setting up libept0 (0.5.26) ...
 Setting up aptitude (0.5.1-1) ...
 Another update is already running: showing its progress.
 Rebuilding Xapian index... 39% 
 Traceback (most recent call last):
   File /usr/sbin/update-apt-xapian-index, line 527, in module
 childProgress.loop()
   File /usr/sbin/update-apt-xapian-index, line 125, in loop
 msg = self.sock.recv(4096)
 socket.timeout: timed out
 dpkg: error processing aptitude (--configure):
  subprocess post-installation script returned error exit status 1
 Processing triggers for python-support ...
 Errors were encountered while processing:
  aptitude

I can't figure out why that exception is raised, however: according to
the exception's documentation, it's raised if the timeout's been set
via a call to settimeout, but there are no such calls in
update-apt-xapian-index.

-- 
Matt http://ftbfs.org/



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org