Yuri
2016-09-01 13:42:02 UTC
Hi all
I couldn't find Twisted-specific group, so posting here.
Recently Twisted 16.4.0 got released. Yesterday I've tried to upgrade it
for my apps and got an error.
I've created simple example, which demonstrates it.
File service.tac:
=======================================
import os
from twisted.application import service, internet
import mymodule
application = service.Application("Demo application")
----------------------------------------
File mymodule.py:
========================================
def myfunction(asd):
""" Stub function """
----------------------------------------
If you try to run it with twistd -y service.tac you'll get an error:
== output ==============================
Unhandled Error
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 648, in run
runApp(config)
File
"/usr/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line
25, in runApp
_SomeApplicationRunner(config).run()
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 379, in run
self.application = self.createOrGetApplication()
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 444, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 455, in getApplication
application = service.loadApplication(filename, style, passphrase)
File
"/usr/local/lib/python2.7/site-packages/twisted/application/service.py",
line 411, in loadApplication
passphrase)
File
"/usr/local/lib/python2.7/site-packages/twisted/persisted/sob.py", line
223, in loadValueFromFile
eval(codeObj, d, d)
File "service.tac", line 7, in <module>
import mymodule
exceptions.ImportError: No module named mymodule
Failed to load application: No module named mymodule
----------------------------------------
The errors comes down to this: twistd script does not add current
working directory to python path (or removes it, I don't know what
exactly happens), so it fails to import any packages/modules from it.
The issue does not appear in previous version (Twisted 16.3.2).
Any ideas what caused it?
I couldn't find Twisted-specific group, so posting here.
Recently Twisted 16.4.0 got released. Yesterday I've tried to upgrade it
for my apps and got an error.
I've created simple example, which demonstrates it.
File service.tac:
=======================================
import os
from twisted.application import service, internet
import mymodule
application = service.Application("Demo application")
----------------------------------------
File mymodule.py:
========================================
def myfunction(asd):
""" Stub function """
----------------------------------------
If you try to run it with twistd -y service.tac you'll get an error:
== output ==============================
Unhandled Error
Traceback (most recent call last):
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 648, in run
runApp(config)
File
"/usr/local/lib/python2.7/site-packages/twisted/scripts/twistd.py", line
25, in runApp
_SomeApplicationRunner(config).run()
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 379, in run
self.application = self.createOrGetApplication()
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 444, in createOrGetApplication
application = getApplication(self.config, passphrase)
--- <exception caught here> ---
File
"/usr/local/lib/python2.7/site-packages/twisted/application/app.py",
line 455, in getApplication
application = service.loadApplication(filename, style, passphrase)
File
"/usr/local/lib/python2.7/site-packages/twisted/application/service.py",
line 411, in loadApplication
passphrase)
File
"/usr/local/lib/python2.7/site-packages/twisted/persisted/sob.py", line
223, in loadValueFromFile
eval(codeObj, d, d)
File "service.tac", line 7, in <module>
import mymodule
exceptions.ImportError: No module named mymodule
Failed to load application: No module named mymodule
----------------------------------------
The errors comes down to this: twistd script does not add current
working directory to python path (or removes it, I don't know what
exactly happens), so it fails to import any packages/modules from it.
The issue does not appear in previous version (Twisted 16.3.2).
Any ideas what caused it?