-1

Google'd but only getting results about how we can create launch.json configs and start the debugging from line #1.

So I have a [big?] Python project that runs from command-line, and I just created a helper method (def pauseHereAndNotifyUserOnSlack(user=<username>) to pause where needed and wait for the user to press a key to exit out of this [infinite] loop and resume the code.

I am wondering if there's a way to attach my python project while the code is paused, inspect the variables and stuff, and resume execution from there?

(Think C#/C++ has this feature, where they attach using symbols and stuff? Not 100% sure how this works. Maybe I am confusing myself?)

Let me know if you guys need more clarification. TIA

scorpion35
  • 944
  • 2
  • 12
  • 30
  • 1
    I am curious about what you mean by " attach my python project ". – kgkmeekg Oct 14 '22 at 17:21
  • 1
    pdb does not have the ability to halt and begin debugging on a running program. You can read more about it in this question https://stackoverflow.com/questions/25308847/attaching-a-process-with-pdb – DDay Oct 14 '22 at 17:30
  • 1
    Thank you @DDay. Your link gave me pointers in finding the answer I am looking for. Somehow I landed on this video and it is exactly what I am looking for - https://www.youtube.com/watch?v=aZJnGOwzHtU&loop=0 – scorpion35 Oct 14 '22 at 18:53
  • 1
    @kgkmeekg Found what I am looking for. https://www.youtube.com/watch?v=aZJnGOwzHtU&loop=0. Was thinking there's a way I can somehow connect vscode with my Python project open to the same project running in cmdline and resume code from some breakpoint. But this video helped me - https://www.youtube.com/watch?v=aZJnGOwzHtU&loop=0 – scorpion35 Oct 14 '22 at 18:56
  • Learnt something new today! Is there any specific reason you are not using PyCharm and the python debugger that comes with it ? – kgkmeekg Oct 14 '22 at 19:34
  • This project is run from command line on CI, for each PR – scorpion35 Oct 14 '22 at 20:47

1 Answers1

0

You don't need to debug your code from line 1, set breakpoints in your code and start debugging from there and inspect variables and can also resume execution from there. (if this is what you were talking about) the play button can be used to resume your execution.example given below

PRINCE
  • 56
  • 3
  • hey, thanks for the answer. Found what I am looking for in this video - https://www.youtube.com/watch?v=aZJnGOwzHtU&loop=0 – scorpion35 Oct 14 '22 at 18:56