How debuging twisted application in PyCharm

与世无争的帅哥 提交于 2019-12-04 05:30:32

问题


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)

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


回答1:


Create a new Run Configuration in PyCharm, under the "Python" section.

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.

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



来源:https://stackoverflow.com/questions/32970894/how-debuging-twisted-application-in-pycharm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!