如何在 PyCharm 中调试扭曲的应用程序 [英] How debuging twisted application in PyCharm

查看:71
本文介绍了如何在 PyCharm 中调试扭曲的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 PyCharm 中调试一个 Twisted 应用程序

I would like to debug a Twisted Application in PyCharm

from twisted.internet import defer
from twisted.application import service, internet
from txjason.netstring import JSONRPCServerFactory
from txjason import handler

class Example(handler.Handler):
    def __init__(self, who):
        self.who = who

    @handler.exportRPC("add")
    @defer.inlineCallbacks
    def _add(self, x, y):
        yield
        defer.returnValue(x+y)

    @handler.exportRPC()
    def whoami(self):
        return self.who

factory = JSONRPCServerFactory()
factory.addHandler(Example('foo'), namespace='bar')

application = service.Application("Example JSON-RPC Server")
jsonrpcServer = internet.TCPServer(7080, factory)
jsonrpcServer.setServiceParent(application)

如何从命令行运行应用程序我知道,但如何在 PyCharm 中开始调试不明白

How to run app from command line I know, but how to start debugging in PyCharm can't understand

推荐答案

创建一个新的 在 PyCharm 中的Python"部分下运行配置.

如果您使用 twistd 启动此应用程序,则将脚本"设置配置为指向该扭曲,以及脚本参数",就像在命令行中一样.您可能希望包含 --nodaemon 选项.

If you start this application using twistd, then configure the "Script" setting to point to that twistd, and the "script parameters" as you would have them on the command line. You'll probably want to include the --nodaemon option.

然后您应该能够在 PyCharm 下运行它,或者 设置断点 并调试它.

You should then be able to Run that under PyCharm, or set breakpoints and Debug it.

这篇关于如何在 PyCharm 中调试扭曲的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆