Ticket #233 (closed defect: fixed)
Issue with Twisted threads
| Reported by: | thijs | Owned by: | thijs |
|---|---|---|---|
| Priority: | major | Milestone: | 0.3 |
| Component: | Remoting | Version: | 0.3 |
| Keywords: | review | Cc: | |
| Fixed in revision: | Branch: | ||
| Author: |
Description (last modified by thijs) (diff)
I received this error while working on a Twisted .tac application.
File "buildbot.tac", line 2, in <module> from pyamf.remoting.gateway.twisted import TwistedGateway File "/Volumes/collab1/Sites/software/pyamf/pyamf/trunk/pyamf/remoting/gateway/twisted.py", line 17, in <module> threads = twisted.internet.threads exceptions.AttributeError: 'module' object has no attribute 'threads' Failed to load application: 'module' object has no attribute 'threads'
Even though it's available:
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import twisted.internet.threads >>>
My .tac:
from pyamf.remoting.gateway.twisted import TwistedGateway from twisted.application import service, internet from twisted.web import static, server, resource def get_list(request): return filter(lambda x: not x.startswith('.'), os.listdir(r'%(basedir)s')) def getWebService(): ''' Return a service suitable for creating an application object. This service is a simple web server that serves files on port 8080 from underneath the current working directory. ''' # create a resource to serve static files root = resource.Resource() root.putChild('gateway', TwistedGateway({ 'smp.getList': get_list, 'getList': get_list })) return internet.TCPServer(8080, server.Site(root)) application = service.Application('Test') # attach the service to its parent application web_service = getWebService() web_service.setServiceParent(application)
I solved the problem by moving the p.r.g.TwistedGateway import into the def:
from twisted.application import service, internet from twisted.web import static, server, resource def get_list(request): return filter(lambda x: not x.startswith('.'), os.listdir(r'%(basedir)s')) def getWebService(): ''' Return a service suitable for creating an application object. This service is a simple web server that serves files on port 8080 from underneath the current working directory. ''' from pyamf.remoting.gateway.twisted import TwistedGateway # create a resource to serve static files root = resource.Resource() root.putChild('gateway', TwistedGateway({ 'smp.getList': get_list, 'getList': get_list })) return internet.TCPServer(8080, server.Site(root)) application = service.Application('Test') # attach the service to its parent application web_service = getWebService() web_service.setServiceParent(application)
So it looks like a import issue with our twisted module?
Attachments
Change History
Note: See
TracTickets for help on using
tickets.



