<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Has anyone been able to use VS Code (not VS Studio) to debug using attach to process? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1185217#M64802</link>
    <description>&lt;P&gt;I spent some time yesterday playing around with the "Attach to process" debugging. Your Python script under test has to have the debugging component in it, which I did with two lines. When the python runs, it opens port 5678 and then you can find the process and attach to it in VS Code. Everything works then - single step, setting breakpoints, changing values of variables...&amp;nbsp;&lt;/P&gt;&lt;P&gt;But sadly when I added that code to a Python Toolbox and ran it from the COMMAND LINE it worked, but when starting it running inside ArcGIS Pro it caused a new copy of Pro to spawn instead of launching the tool. So close! But useless.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Run this from the command line, then connect to it from VSCode.
Set a breakpoint inside the loop and it should stop there.
Step through (F10) the loop a few times.
When you are done you could set loop to False in the debugger
to see it exit the loop and terminate.
"""
import time
import debugpy
debugpy.listen(5678)

tock = 1
loop = True # Set this to False in the debugger to end the program.
while loop :
    print("Tick", tock)
    tock += 1
    time.sleep(1)
print("We're done here.")&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 22 Jun 2022 19:20:04 GMT</pubDate>
    <dc:creator>Brian_Wilson</dc:creator>
    <dc:date>2022-06-22T19:20:04Z</dc:date>
    <item>
      <title>Has anyone been able to use VS Code (not VS Studio) to debug using attach to process?</title>
      <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184117#M64780</link>
      <description>&lt;P&gt;I'm interested if anyone (or if it's possible to) to use VS Code to to debug python toolboxes using the Attach to process functionality mentioned here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/get-started/debugging-python-code.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/2.8/arcpy/get-started/debugging-python-code.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;VS Code has the functionality and I think I'm configuring it correctly but when I start a debug session an begin stepping through break points nothing seems to be connected.&lt;/P&gt;&lt;P&gt;Is this possible with Pro? Has anyone done this succesfully?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jun 2022 07:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184117#M64780</guid>
      <dc:creator>I_AM_ERROR</dc:creator>
      <dc:date>2022-06-18T07:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Has anyone been able to use VS Code (not VS Studio) to debug using attach to process?</title>
      <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184311#M64791</link>
      <description>&lt;P&gt;It seems others are struggling with this as well.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/has-anyone-successfully-attached-the-vscode/m-p/1092605" target="_blank"&gt;Has anyone successfully attached the VSCode Debugg... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Although it's referring to ArcMap, you could try this.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/arcgis-desktop/analytics/how-to-debug-python-toolboxes-in-3-easy-steps/" target="_blank"&gt;How to Debug Python Toolboxes in 3 Easy Steps (esri.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 14:21:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184311#M64791</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-06-20T14:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Has anyone been able to use VS Code (not VS Studio) to debug using attach to process?</title>
      <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184443#M64794</link>
      <description>&lt;P&gt;Thanks, read through those and tried ESRI's recommendations but no luck so far....&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 20:07:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184443#M64794</guid>
      <dc:creator>I_AM_ERROR</dc:creator>
      <dc:date>2022-06-20T20:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Has anyone been able to use VS Code (not VS Studio) to debug using attach to process?</title>
      <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184832#M64799</link>
      <description>&lt;P&gt;Pretty much what they describe is what I do.&amp;nbsp; The bottom of the .pyt file has code that will run in VS Code but not in the actual toolbox in ArcGIS Pro.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Unit test
if __name__ == "__main__":

    class Messenger(object):
        def addMessage(self, message):
            print(message)

    hello = Hello_Tool()
    hello.execute(None, Messenger())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What have you tried so far?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 19:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1184832#M64799</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-06-21T19:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Has anyone been able to use VS Code (not VS Studio) to debug using attach to process?</title>
      <link>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1185217#M64802</link>
      <description>&lt;P&gt;I spent some time yesterday playing around with the "Attach to process" debugging. Your Python script under test has to have the debugging component in it, which I did with two lines. When the python runs, it opens port 5678 and then you can find the process and attach to it in VS Code. Everything works then - single step, setting breakpoints, changing values of variables...&amp;nbsp;&lt;/P&gt;&lt;P&gt;But sadly when I added that code to a Python Toolbox and ran it from the COMMAND LINE it worked, but when starting it running inside ArcGIS Pro it caused a new copy of Pro to spawn instead of launching the tool. So close! But useless.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""
Run this from the command line, then connect to it from VSCode.
Set a breakpoint inside the loop and it should stop there.
Step through (F10) the loop a few times.
When you are done you could set loop to False in the debugger
to see it exit the loop and terminate.
"""
import time
import debugpy
debugpy.listen(5678)

tock = 1
loop = True # Set this to False in the debugger to end the program.
while loop :
    print("Tick", tock)
    tock += 1
    time.sleep(1)
print("We're done here.")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 19:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/has-anyone-been-able-to-use-vs-code-not-vs-studio/m-p/1185217#M64802</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-06-22T19:20:04Z</dc:date>
    </item>
  </channel>
</rss>

