jborean93 / vscode-ansibug

VSCode Extension for Debugging Ansible Playbooks
MIT License
4 stars 0 forks source link

No clean way to stop the current playbook run #7

Open mijofa opened 1 month ago

mijofa commented 1 month ago

This maybe belongs on the Ansibug repo, I'm really not sure. I've just set this up tonight, and it's great. Only issue is it doesn't stop when pressing the 'stop' button in the debugger controls, and it reacts weirdly to Ctrl-C.

Pressing stop in the debugger controls (or Shift-F5) seems to disconnect vscode from the debugger without actually stopping the process. While pressing Ctrl-C gives me this (expected) message:

^C [ERROR]: User interrupted execution

but just sits there forever, never disconnecting the debugger from vscode and never stopping the process.

If I press Ctrl-C a second time I get::

^CException ignored in: <module 'threading' from '/usr/lib/python3.11/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1583, in _shutdown
    lock.acquire()
KeyboardInterrupt: 

Which is "probably" fine, but it does make things look like it doesn't shut down properly.

When using 'debugpy' on Python code it will stop the process and disconnect with both Ctrl-C & Shift-F5

jborean93 commented 1 month ago

Thanks for the bug report.

The stop action (default for launch) should stop the entire playbook while disconnect (shift+F5 for launch) should have it continue running but with the debugger detatched This is documented under https://jborean93.github.io/ansibug/stepping.html. I've not tested out ctrl+c but I wouldn't be surprised if that had bugs which need to be fixed.

Can you share an example playbook and the details of when you tried to stop it? Unfortunately there's a few things that need to happen for this to work properly so I'll need to figure out what is going wrong with the sequence that was used.

mijofa commented 1 month ago

I find disconnect and stop behave exactly the same for me, and restart doesn't seem to work at all.

Here's a sample playbook: ansibug-issue7.yaml.txt Includes a couple of pause tasks, and a wait_for task for good measure. I've seen this with a few different playbooks though, haven't seen things work normally at all.

My launch.json config looks like:

        {
            "name": "Ansibug: Launch Current File",
            "type": "ansible",
            "request": "launch",
            "playbook": "${file}",
            "cwd": "/tmp/"
        }