[英]run in twistd instead of python
I need to debug my twisted application. 我需要调试扭曲的应用程序。 I am using pycharm and from what I understand I can start my application in twistd with the --no-daemon option in order to step through the code.
我正在使用pycharm,据我了解,我可以使用--no-daemon选项扭曲启动我的应用程序,以逐步执行代码。
I have the following code to start the server. 我有以下代码来启动服务器。
def main():
log.startLogging(sys.stdout)
contextFactory = ssl.DefaultOpenSSLContextFactory(os.environ['SSLKEY'],
os.environ['SSLCERT'])
factory = WebSocketServerFactory(u"wss://0.0.0.0:8080")
factory.protocol = MyServerProtocol
resource = WebSocketResource(factory)
root = create_root()
saml_manager = SamlManager()
saml_manager.init_app(root)
root.putChild(b"ws", resource)
site = Site(root)
reactor.listenSSL(8080, site, contextFactory)
reactor.run()
if __name__ == '__main__':
main()
I see twistd has a -y option but I have not been able to get it to run my app. 我看到Twisted有一个-y选项,但是我无法使其运行我的应用程序。
My directory tree has is as follows. 我的目录树如下。
.
├── app
│ ├── __init__.py
│ ├── auth.py
│ ├── certs
│ └── index.html
├── run.py
├── saml
│ └── settings.json
└── venv
├── bin
├── include
├── lib
└── pip-selfcheck.json
7 directories, 6 files
I have been running the application by executing run.py which calls the main() function. 我通过执行run.py来运行应用程序,该调用了main()函数。
How can I start this application with twistd on the command line so I can debug the app? 如何在命令行上加捻启动该应用程序,以便调试该应用程序?
For reference I am refering to How debuging twisted application in PyCharm in order to try and debug the twisted app in pycharm. 作为参考,我指的是如何在PyCharm中调试扭曲的应用程序 ,以便尝试在pycharm中调试扭曲的应用程序。
If there is a better way to do this so I can set breakpoints in requests please let me know. 如果有更好的方法可以执行此操作,那么我可以在请求中设置断点,请告诉我。
Thanks! 谢谢!
Disregard this question. 忽略这个问题。 I apparently had a bad decorator that was causing a redirect loop and also prevented me from debugging.
我显然有一个错误的装饰器,这导致了重定向循环,也阻止了我进行调试。 Once I remove that decorator I am able to debug like normal.
删除该装饰器后,便可以像平常一样进行调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.