1

I just tried to use the Python module twisted.internet for an XBMC add-on that I am currently writing. When I tried to execute my add-on, I got an exception that I could not understand. I was quite suprised when I noticed that the following lines were causing all the troubles:

import xbmc, xbmcgui, xbmcaddon # Can be removed; doesn't change anything.
from twisted.internet import reactor, defer

Question: How can I use twisted for the development of my XBMC add-on? Any help would be appreciated!

Unfortunately, I am new to both, XBMC and twisted and there are little more details that I can provide. I think that the addon is not executed in the main thread. I am using XBMC 11 for testing at the moment. (Update: I am using the most recent Debian testing packages of XBMC, Python and twisted. Importing and using the module works from regular scripts and from an XBMC service, but not from XBMC scripts.) The stacktrace from the xbmc.log file is:

File "/home/markus/.xbmc/addons/script.marmay.wol/timewol.py", line 2, in <module>
  from twisted.internet   import  reactor, defer
File "/usr/lib/python2.7/dist-packages/twisted/internet/reactor.py", line 37, in <module>
  from twisted.internet import default
File "/usr/lib/python2.7/dist-packages/twisted/internet/default.py", line 50, in <module>
  install = _getInstallFunction(platform)
File "/usr/lib/python2.7/dist-packages/twisted/internet/default.py", line 44, in _getInstallFunction
  from twisted.internet.pollreactor import install
File "/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.py", line 19, in <module>
  from zope.interface import implements
File "/usr/lib/python2.7/dist-packages/zope/interface/__init__.py", line 58, in <module>
  _wire()
File "/usr/lib/python2.7/dist-packages/zope/interface/interface.py", line 805, in _wire
  classImplements(Attribute, IAttribute)
File "/usr/lib/python2.7/dist-packages/zope/interface/declarations.py", line 447, in classImplements
  spec = implementedBy(cls)
File "/usr/lib/python2.7/dist-packages/zope/interface/declarations.py", line 318, in implementedByFallback
  if isinstance(spec, Implements):
TypeError: 'NoneType' object is not callable

This is the first relevant error message.

Thanks for your help!

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Markus Mayr
  • 4,038
  • 1
  • 20
  • 42
  • 1
    How did you install `twisted`? Clearly there's something wrong with your installation. And it will be a lot easier to debug this by just typing `import twisted.internet`, then (if that works) `from twisted.internet import reactor` and `from twisted.internet import defer`, into an interactive interpreter. So, can you try that? – abarnert Feb 28 '13 at 20:57
  • 1
    Also, what platform are you on, and what version of Twisted (and where did you get Python 2.7 from)? I've seen something similar with cygwin, where Twisted figures out that it shouldn't use `poll` even though it exists, but then gets confused about what it _should_ use, although I think that was a bug fixed a few years ago. – abarnert Feb 28 '13 at 20:58
  • 1
    I forgot to mention that I was using `twisted` from an XBMC service successfully. It also works in regular scripts. I am using up-to-date packages from Debian testing. – Markus Mayr Feb 28 '13 at 20:59
  • 2
    Does "import zope.interface" work in a normal Python shell? It looks like your problem is inside that package, not so much in Twisted itself. `if isinstance(spec, Implements):` should really not fail with that TypeError. It suggests that `isinstance` has been set to `None` somehow, or that a zope.interface special method (`__subclasscheck__` perhaps?) is broken. – Jean-Paul Calderone Feb 28 '13 at 22:23
  • @Jean-PaulCalderone: Thanks for your suggestions and sorry that I did not reply earlier. Indeed, the problem is caused by `zope.interface`. More precisely by importing it twice (from different *contexts* / threads / whatever). Deactivating the above-mentioned XBMC service that also uses `zope.interface` *resolves* the problem. If I find a proper solution for this issue, I will update my question. – Markus Mayr Mar 03 '13 at 10:03

0 Answers0