gpt4 book ai didi

python - twisted的twistd工具解析命令行参数

转载 作者:行者123 更新时间:2023-12-01 05:33:05 29 4
gpt4 key购买 nike

我有一个带有简单服务的简单 .tac 文件,我以以下方式启动它:

twistd -y service.tac

一切正常。但在 tac 文件中,我有一个用于我的服务的硬编码端口,我想使其动态。我想让它工作的最理想的方式是通过标准的 unix 命令行参数:

twistd -y service.tac --port 8081

然后我想访问 .tac 文件内某处的 port 变量。就像标准 python 模块一样:optparse 和 argparse。我在 Twisted 中寻找这样的解决方案,我只找到 https://twistedmatrix.com/documents/12.0.0/core/howto/options.html#auto6恐怕这不是我需要的,因为我收到此错误:

$ twistd -y service.tac 
/usr/bin/twistd: option -y not recognized
/usr/bin/twistd: Try --help for usage details.

有人知道如何参数化 twistd 工具吗?

最佳答案

看起来 Twisted 的执行方式似乎记录在此处:

https://twistedmatrix.com/documents/12.0.0/core/howto/tap.html

您编写的插件添加了可通过 CLI 使用的“子命令”

关于python - twisted的twistd工具解析命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19733812/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com