Forum Discussion

mfoster711's avatar
mfoster711
Regular Contributor
2 months ago

TestComplete Freeze up after Stop Button

TestComplete will freeze up if I press the stop button in the following example. 

  • Add a breakpoint in the DummyFunction on the line marked "Use breakpoint on this line.....". 
  • Run the Main function
  • When the script pauses on the breakpoint, click the TestComplete Stop button.
  • TestComplete will freeze and only option is to force close in Task Manager

Any clue why this is happening?

class dummyClass:
    @staticmethod
    def DummyFunction():
        try:
            pass # Do some work. Use breakpoint on this line and then click Stop Button
            return "some value"
            
        except Exception as err:
            Log.Error("DummyFunction Exception: "+str(err.args))
            return ""

# This main function is designed to run endlessly until user presses Stop Button 
def main():
    try:
        while True:
            return_value = dummyClass.DummyFunction()
            if return_value != "":
                pass  # Do some tasks if return_value is not blank
                aqUtils.Delay(60000, "Wait for a minute after performing work")
            else:
                aqUtils.Delay(60000, "Wait for a minute")
    
    except Exception as err:
        Log.Error("Main Exception: "+str(err.args))



6 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    The behaviour you're experiencing is due to the difference between debugging mode and normal execution. Using Python, similar Ctrl + C doesn't work immediately when debugging as the debugger has control over the execution, not the Python interpreter's normal signal handling.

    Also, there are known issues with the latest version of TC and Python.

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    I modified the code to include some extra debugging and remove the infinite loop. 

    • There are two lines marked Example 1 and Example 2.
    • I paused the script on the line marked Example 1 and clicked Stop, the script exits immediately. 
    • I paused on Example 2 and clicked Stop, the script seems to continue pressing when you review the log.

    See below for logs from the two different runs.

    class dummyClass:
        @staticmethod
        def DummyFunction():
            Log.Message("DummyFunction")
            try:
                pass # Example 2 - Use breakpoint on this line and then click Stop Button. Scripts seems to keep running 
                return "some value"
                
            except Exception as err:
                Log.Error("DummyFunction Exception: "+str(err.args))
                return ""
    
    # This main function is designed to run endlessly until user presses Stop Button
    def main():
        try:
            i = 0
            while True:
                Log.Message("Main. i="+str(i))
                i += 1
                return_value = dummyClass.DummyFunction()
                if return_value != "":
                    pass  # Example 1 - Use breakpoint on this line and then click Stop Button. Scripts exits immediately
                    aqUtils.Delay(60000, "Wait for a minute after performing work")
                    if i > 5:
                        break
                else:
                    aqUtils.Delay(60000, "Wait for a minute")
        
        except Exception as err:
            Log.Error("Main Exception: "+str(err.args))

     

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    Why does script keep processing if I use Stop Button inside the dummy function?

    • Hassan_Ballan's avatar
      Hassan_Ballan
      Icon for Champion Level 3 rankChampion Level 3

      Looks like a TestComplete internal deadlock — it happens when you hit Stop while paused inside a try/except block. The debugger and Python engine both try to control the same thread and end up freezing TC. It’s reproducible and not script-related, so it’s worth reporting to SmartBear Support with a small sample project attached so they can log it as a bug.

      🤖 AI-assisted response
      👍 Found it helpful? Click Like
      ✅ Issue resolved? Click Mark as Solution

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    Thanks for feedback. I will submit something to Smartbear to report this. I was able to come up with a workaround for now in case anybody else encounters this issue. 

    I added a timer inside my While loop that times how long the aqUtils.Delay takes. It should take 6 seconds in the following example but aqUtils.Delay seems to get skipped when you press stop button. This cause the IF statement to be true which then results in the BREAK statement getting executed and stops the infinite loop.

     

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    You could try to slow the test execution in your project settings and see if it helps.  However in my experience coding loops like this does not turn out well. 

    ... If you find my posts helpful drop me a like! 👍 Be sure to mark or post the solution to help others out and/or to credit the one who helped you. 😎