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
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.
Related
I'm trying to make a program (with GUI) that shows some informations.
I would like to update these informations from outside events.
e.g.
I have another script that do his tasks once a day (once a day a NEW process runs and does it's job), after this job completes I would like to update the informations in my GUI,that is always displayed on my monitor,without closing and reopening it.
Is there a way to retrieve the GUI process from outside and run functions inside it? (or a better way if u can help me)
I dont even know where to start, I feel that is something with threading,but dont know how to proper do it.
the main instance is in an infinite loop waiting for communication commands to afterwords replay this. For the very first step, I would like, somehow, to stop the dynamic analysis on this main instance with Valgrind so the CI on Gitlab can run until the end without having to cancel it and also having some results, perhaps this result does not tell much. Then as a second step, I would write some special cases that Valgrind could analyze. I'm looking for a workaround for this problem.
Please let me know if I can add some other info about my question.
I'm using Pycharm and playing with the profiler it has built in. I've keyed in on some areas where my code can be optimized but I was wondering if there was a way to step through the code and see how long each line took to execute as I stepped through without having to rerun all my code in the profiler.
I think the closes you could do is put a breakpoint
then open up the debugger and enter console mode
and execute the statement as started=time.time();my_function();print("Took %0.2fs"%(time.time()-started))
I am using Python C Api to embed a python in our application. Currently when users execute their scripts, we call PyRun_SimpleString(). Which runs fine.
I would like to extend this functionality to allow users to run scripts in "Debug" mode, where like in a typical IDE, they would be allowed to set breakpointsm "watches", and generally step through their script.
I've looked at the API specs, googled for similar functionality, but did not find anything that would help much.
I did play with PyEval_SetTrace() which returns all the information I need, however, we execute the Python on the same thread as our main application and I have not found a way to "pause" python execution when the trace callback hits a line number that contains a user checked break point - and resuming the execution at a later point.
I also see that there are various "Frame" functions like PyEval_EvalFrame() but not a whole lot of places that demo the proper usage. Perhaps these are the functions that I should be using?
Any help would be much appreciated!
PyEval_SetTrace() is exactly the API that you need to use. Not sure why you need some additional way to "pause" the execution; when your callback has been called, the execution is already paused and will not resume until you return from the callback.
Will it is possible to run a small set of code automatically after a script was run?
I am asking this because for some reasons, if I added this set of code into the main script, though it works, it will displays a list of tab errors (its already there, but it is stating that it cannot find it some sort).
I realized that after running my script, Maya seems to 'load' its own setup of refreshing, along with some plugins done by my company. As such, if I am running the small set of code after my main script execution and the Maya/ plugins 'refresher', it works with no problem. I had like to make the process as automated as possible, all within a script if that is possible...
Thus is it possible to do so? Like a delayed sort of coding method?
FYI, the main script execution time depends on the number of elements in the scene. The more there are, it will takes longer...
Maya has a command Maya.cmds.evalDeferred that is meant for this purpose. It waits till no more Maya processing is pending and then evaluates itself.
You can also use Maya.cmds.scriptJob for the same purpose.
Note: While eval is considered dangerous and insecure in Maya context its really normal. Mainly because everything in Maya is inherently insecure as nearly all GUI items are just eval commands that the user may modify. So the second you let anybody use your Maya shell your security is breached.