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.
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.
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.
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.
If there is a better way to do this so I can set breakpoints in requests please let me know.
Thanks!