Breakpoint in VS Code


#1

Hi, I’m quite new to Python, so please excuse my ignorance.

I’m writing and running a bot locally, writing in Python in VS code. However I can’t find a way to hit a breakpoint in the bot, due to it being run by the halite.exe rather than as a standalone python script.

I realise I could just stick a load of logging statements into the bot, but it would be easier to see how things are going by being able to break in the Python of the bot. Would anyone know if this is possible and, if it is, how would I do it?

Thanks.


#2

Hey,
There might be a cleaner solution but i usually just use a print statement as breakpoint. The code throws an error but it is just really simple to stop the code that way. I hope I understood your question correctly.:slight_smile:


#3

Does VSCode let you attach to a running process? You could run halite with --no-timeout, then put a sleep call in your bot to give you enough time to attach. (VSCode would also need to not interfere with stdin/stdout of the bot).

Alternatively, you could use a proxy bot - here’s some discussions on that:


#4

Hi, I actually wanted to set a breakpoint so that I can inspect the variables program flow etc., is using a print statement not just the same as logging? Thanks anyway.


#5

Your suggestion was a good one and I have actually been able to get a breakpoint to hit in the Python bot when running Halite and then attaching to the Python process - unfortunately I wasn’t able to do this in VS Code as it seems that it doesn’t yet have the ability to attach to a local process (supposedly it can attach to remote processes) but I was able to attach in Visual Studio using your method. Thanks!