Debugger: way to add some "clean-up" code to be executed before stopping/detaching?
Hi! I'm trying to debug code that opens up a database connection and, for now, frequently raises an exception before getting to the code that closes the connection. Thus, when I restart the code, I can't reconnect, until the connection times out. I've realized that I can put the code in a try block that catches exceptions and closes the DB before exiting, and I also figured out that if I've broken in the debugger and want to detach, I can dig down to the DB connection object and issue its terminate method, but is there a way I can automate this so that such a disconnect is automatically tried for me whenever I select Stop under the Run menu? Thanks!
Please sign in to leave a comment.
http://forum.jetbrains.com/thread/PyCharm-2234
https://youtrack.jetbrains.com/issue/PY-13316
--
David Lawrence Goldsmith (DLG)
Software Engineer
Fishery Resource Analysis and Monitoring Division
Northwest Fisheries Science Center – NOAA
2725 Montlake Blvd E.
Seattle, WA 98112
(206) 302-2420 <%28206%29%20860-3341> (w)
(360) 481-3800 (c)
https://youtrack.jetbrains.com/issue/PY-13316
I suppose you could star the issue and/or comment there. I would also welcome a fix.