DroneD / droned

DroneD - Application Service Framework
Apache License 2.0
0 stars 1 forks source link

Missing attributes in reactor on Twisted 8 #4

Closed jacobrichard closed 11 years ago

jacobrichard commented 11 years ago

Droned crashes with the following message on Centos 6.2 with Twisted 8:

Traceback (most recent call last): File "/usr/share/droned/droned", line 32, in from droned.protocols.psproxy.apiwrapper import process File "/usr/share/droned/lib/droned/protocols/psproxy/apiwrapper/process.py", line 114, in globals()[var] = threaded(val) File "/usr/share/droned/lib/droned/protocols/psproxy/apiwrapper/process.py", line 73, in threaded @deferredInThreadPool(pool=config.reactor.getThreadPool(),R=config.reactor) AttributeError: 'SelectReactor' object has no attribute 'getThreadPool'

Possibly, a zope adapter could be built to adapt the Twisted 8 interface to match the newer API.

Here is an example that is not completed, but conveys the idea.

from zope.interface import Interface, implements
from twisted.internet.interfaces import IReactorFDSet
from twisted.python import components

class AdaptToV10API:
        implements(IReactorFDSet)

        def __init__(self, original):
                self.original = original

        def getThreadPool(self):
            """
            See L{twisted.internet.interfaces.IReactorThreads.getThreadPool}.
            """
            if self.original.threadpool is None:
                self.original._initThreadPool()
            return self.original.threadpool

components.registerAdapter(AdaptToV10API, reactor, IReactorFDSet)
JustinVenus commented 11 years ago

Confirmed. Let's fix it.

JustinVenus commented 11 years ago

closing as fixed.