python - 当我运行不带任何选项的 `twistd` 命令时,为什么我的扭曲插件没有出现?

标签 python twisted twistd

这是我的 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/

相关文章:

python - 用Python通过打印机打开till

python - 有没有办法在 python 中将 xml 子标签存储在列表中?

python - Spyder 默认模块导入列表

python - 如何从Tensorflow中的多个对齐数据集中随机选择数据?

python - reactor.connectTCP 可以在 twisted python 中的 reactor.run 之后发生吗?

python - Buildbot 不以默认配​​置启动

twisted - Twisted .tac 文件中的用户/应用程序特定值

python - 将不重复的随机数 append 到列表中

python - 使用 Twisted 子进程和 virtualenvwrapper 时如何导入模块?

python - 防止 cyclone 评估 Handlebar 的模板