Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 08 Jul 2008 22:19:27 +1100
From:      Andrew MacIntyre <andymac@bullseye.apana.org.au>
To:        Kris Kennaway <kris@FreeBSD.org>
Cc:        neal@nelson.name, wxs@FreeBSD.org, python@FreeBSD.org
Subject:   Re: py-bittorrent/twistedCore broken on 8.0?
Message-ID:  <48734D3F.5070008@bullseye.andymac.org>
In-Reply-To: <48711120.1000209@FreeBSD.org>
References:  <48711120.1000209@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kennaway wrote:

> I am trying to use the python bittorrent tracker with python 2.5 and 
> FreeBSD 8.0, but I am getting a lot of errors from the kqueue reactor in 
> twisted.
> 
> pointyhat# bittorrent-tracker
> track: create_serversocket, port= 80
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.5/site-packages/BitTorrent/track.py", 
> line 925, in track
>     r.listen_forever()
>   File 
> "/usr/local/lib/python2.5/site-packages/BitTorrent/RawServer_twisted.py", 
> line 790, in listen_forever
>     reactor.run(installSignalHandlers=False)
>   File "/usr/local/lib/python2.5/site-packages/BTL/reactor_magic.py", 
> line 60, in run_default
>     return old_run(**kw)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 220, in run
>     self.mainLoop()
> --- <exception caught here> ---
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 231, in mainLoop
>     self.doIteration(t)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/kqreactor.py", 
> line 169, in doKEvent
>     selectable = selectables[fd]
> exceptions.KeyError: 4L
> Traceback (most recent call last):
>   File "/usr/local/lib/python2.5/site-packages/BitTorrent/track.py", 
> line 925, in track
>     r.listen_forever()
>   File 
> "/usr/local/lib/python2.5/site-packages/BitTorrent/RawServer_twisted.py", 
> line 790, in listen_forever
>     reactor.run(installSignalHandlers=False)
>   File "/usr/local/lib/python2.5/site-packages/BTL/reactor_magic.py", 
> line 60, in run_default
>     return old_run(**kw)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 220, in run
>     self.mainLoop()
> --- <exception caught here> ---
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 231, in mainLoop
>     self.doIteration(t)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/kqreactor.py", 
> line 169, in doKEvent
>     selectable = selectables[fd]
> exceptions.KeyError: 4L
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.5/site-packages/BitTorrent/RawServer_twisted.py", 
> line 790, in listen_forever
>     reactor.run(installSignalHandlers=False)
>   File "/usr/local/lib/python2.5/site-packages/BTL/reactor_magic.py", 
> line 60, in run_default
>     return old_run(**kw)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 220, in run
>     self.mainLoop()
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/posixbase.py", 
> line 228, in mainLoop
>     self.runUntilCurrent()
> --- <exception caught here> ---
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/base.py", line 
> 561, in runUntilCurrent
>     call.func(*call.args, **call.kw)
>   File 
> "/usr/local/lib/python2.5/site-packages/BitTorrent/HTTPHandler.py", line 
> 175, in connection_flushed
>     connection.shutdown(1)
>   File 
> "/usr/local/lib/python2.5/site-packages/BitTorrent/RawServer_twisted.py", 
> line 238, in shutdown
>     self.transport.loseWriteConnection()
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/abstract.py", 
> line 244, in loseWriteConnection
>     self.startWriting()
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/abstract.py", 
> line 273, in startWriting
>     self.reactor.addWriter(self)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/kqreactor.py", 
> line 107, in addWriter
>     self._updateRegistration(fd, EVFILT_WRITE, EV_ADD)
>   File 
> "/usr/local/lib/python2.5/site-packages/twisted/internet/kqreactor.py", 
> line 89, in _updateRegistration
>     kq.kevent([kevent(*args)], 0, 0)
> exceptions.OSError: [Errno 9] Bad file descriptor
> [...]
> 
> i.e. just it is getting exceptions when doing nothing at all, so it 
> seems to be completely broken.
> 
> Have you tried this, or do you know where to begin looking at what might 
> be wrong?

I know very little about Twisted, but I seem to recall that it offers
a range of different reactors; if you can find where in bittorrent its
deciding to use the kqreactor, you might be able to force it to use an
alternate reactor (such as one based on select() or poll()).

If you can change the reactor and get something that works, that would
suggest some issue with the kqreactor, at least on 8.x.

-- 
-------------------------------------------------------------------------
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac@bullseye.apana.org.au  (pref) | Snail: PO Box 370
        andymac@pcug.org.au             (alt) |        Belconnen ACT 2616
Web:    http://www.andymac.org/               |        Australia



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48734D3F.5070008>