aws / aws-iot-device-sdk-python-v2

Next generation AWS IoT Client SDK for Python using the AWS Common Runtime
Apache License 2.0
408 stars 213 forks source link

Event Loop Debugging? #170

Closed Sylphe88 closed 3 years ago

Sylphe88 commented 3 years ago

Platform/OS/Device Windows 10, Python 3.7.5, Pycharm 2020.3.4, pydev debugger (build 203.7717.65)

Describe the question I'm aware this may not really be a 100% awsiot question, but this got me stuck for a quite a while now. I'm evaluating whether it's a good time to migrate from AWSIoTPythonSDK to awsiotsdk and so far it's working pretty good, but I've been completely unable to debug my code running in callbacks (using breakpoints and step-by-step). This applies to the pubsub sample (can't step into the on_message_received callback). I guess it's related to the event loops created by C code, which make it more difficult to attach to pydevd? However, I have mostly been successful at debugging threads in my Python apps, so there migh be a catch with this?

Thanks a lot for the help & advice!

jmklix commented 3 years ago

Have you tried using debugpy? Just pip install debugpy and add the following to your project:

import debugpy
debugpy.debug_this_thread()

*I tried this is vscode so let me know if this doesn't work in pydev

Sylphe88 commented 3 years ago

I managed to use it in VSCode, but it looks like debugpy interfers with the native pydev from Pycharm, resulting in ImportError: cannot import name 'pydevd_defaults' from '_pydevd_bundle' (C:\Program Files\JetBrains\PyCharm Community Edition 2020.3.4\plugins\python-ce\helpers\pydev\_pydevd_bundle\__init__.py)

So "as expected" it looks like the issue may be with their debugger. Thanks for the tip!

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.