这是我的 twistd
插件的当前状态,该插件位于 project_root/twisted/plugins/my_plugin.py
:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from zope.interface import implements
from twisted.plugin import IPlugin
from twisted.python.usage import Options
from twisted.application import internet, service
from mylib.io import MyFactory
class Options(Options):
"""Flags and options for the plugin."""
optParameters = [
('sock', 's', '/tmp/io.sock', 'Path to IO socket'),
]
class MyServiceMaker(object):
implements(service.IServiceMaker, IPlugin)
tapname = "myplugin"
description = "description for my plugin"
options = Options
def makeService(self, options):
return internet.UNIXServer(options['sock'], MyFactory())
project_root/twisted/plugins/
中没有__init__.py
文件- 从项目根目录运行时,
twistd
的输出不显示我的插件 - 我通过
python setup.pydevelop --user
安装了我的库,并且可以从任何地方导入它
有什么想法吗?
最佳答案
正如所怀疑的,事情非常简单:我需要实例化 MyServiceMaker
的实例,因此只需添加 service_maker = MyServiceMaker()
脚本底部修复了该问题。
关于python - 当我运行不带任何选项的 `twistd` 命令时,为什么我的扭曲插件没有出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26695219/