application is Not responding
-
I have an application that has a stacked widget in which I have 3 windows.
When I am running the application there is a function that will run continuously for up to 30 sec to 1 min or more at this time if I am moving to another application and come back to the PYQt5 application it is showing not responding.
how to solve it??
-
I have an application that has a stacked widget in which I have 3 windows.
When I am running the application there is a function that will run continuously for up to 30 sec to 1 min or more at this time if I am moving to another application and come back to the PYQt5 application it is showing not responding.
how to solve it??
@Gokul2002 said in application is Not responding:
When I am running the application there is a function that will run continuously for up to 30 sec to 1 min or more at this time if I am moving to another application and come back to the PYQt5 application it is showing not responding.
You are probably blocking the main/GUI thread.
how to solve it??
Make it non blocking by calling the function in another thread.
-
I tried with a thread but it didn't solve
def thread(self):
t1=Thread(target=self.connect)
t1.start()self. connect is the function that run for 30 sec to 1 min
thread function will connect to the button press
@Gokul2002 t1 is a local variable inside def thread(self) - think about its lifetime.
-
One more thing I miss to add is the main window UI is in one file and connect is in another file then how to link with the thread
@Gokul2002 said in application is Not responding:
main window UI is in one file and connect is in another file then how to link with the thread
I don't understand the problem.
And you also did not respond to my previous comment... -
@Gokul2002 said in application is Not responding:
main window UI is in one file and connect is in another file then how to link with the thread
I don't understand the problem.
And you also did not respond to my previous comment... -
I have two files one is the main UI file and another is a UI file.
This main UI and other UI files are linked.In the main UI if he pressed edit the the UI will go to the Another function and the UI is updated. but in that UI there is one function called connect it will take 30sec to 1min to complete the task in the mean time if we shift to another application and come back to the application it is showing the not responding unit that function is completed but once the function execution is completed the UI is updating with out any issue
-
I have two files one is the main UI file and another is a UI file.
This main UI and other UI files are linked.In the main UI if he pressed edit the the UI will go to the Another function and the UI is updated. but in that UI there is one function called connect it will take 30sec to 1min to complete the task in the mean time if we shift to another application and come back to the application it is showing the not responding unit that function is completed but once the function execution is completed the UI is updating with out any issue
@Gokul2002 Nothing what you wrote is related to what I wrote: "t1 is a local variable inside def thread(self) - think about its lifetime."
-
@Gokul2002 Nothing what you wrote is related to what I wrote: "t1 is a local variable inside def thread(self) - think about its lifetime."
-
@Gokul2002 What do you think how long t1 lives/exists bellow? Think about its scope.
def thread(self): t1=Thread(target=self.connect) t1.start()
-
@Gokul2002 What do you think how long t1 lives/exists bellow? Think about its scope.
def thread(self): t1=Thread(target=self.connect) t1.start()
-
@Gokul2002 And this is your problem: the Thread instance will be destroyed while the thread is still running (start() is asynchronous, right?).
-
@Gokul2002
In Python yourThread
will be destroyed immediately after thet1.start()
, when it exitsthread()
.Additionally, why are you trying to do a
connect()
in a thread? I can understand a slot needing to run in a thread, but not aconnect()
statement, that should complete immediately.