Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt (PySide) application stops working after several days
Forum Updated to NodeBB v4.3 + New Features

Qt (PySide) application stops working after several days

Scheduled Pinned Locked Moved Unsolved General and Desktop
pysidelinux mintqt4.8.7
6 Posts 3 Posters 1.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nekitamtip
    wrote on 29 Jul 2018, 11:36 last edited by
    #1

    Hi,

    I have an interesting problem with Python Qt (PySide) application running on linux. App contains about 10-20 active threads, a lot of timers and signals. After some period of usage (several days), the application stops working - application remains running, but it seems like at that moment all timers and signals stop working. I have created a thread responsible only for writing a simple message to log every 10 seconds and at the moment when the error occurs it also stops with writing to log. I have checked the system status, and everything seems OK (a lot of available RAM). Python doesn't raise any errors neither Qt writes any error or warning messages to the console.

    Did anybody encounter a similar problem? Is there any limit on a number of emitted signals? Does Qt produce some logs or can I enable some Qt debug mode? Any suggestion on how to debug a problem like this is welcome.

    I am running Python 2.7.12, PySide version 1.2.2 and QtCore version 4.8.7 on Linux Mint 18.1 Serena - Cinnamon 64-bit (based on Ubuntu 16.04).

    Thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Jul 2018, 17:43 last edited by
      #2

      Hi,

      I have no experience with PySide 1 so those are just questions/ideas to try to find the issue.

      Are you creating new threads regularly ?
      Are you creating files ? If so are you closing them properly ?
      Is it a 32 bit application running in your 64 bit system ?

      On a side note, Qt 4 has reached end of life a long time ago and PySide 1 as well. If possible, you should consider updating to Qt 5 and PySide 2 which just got released.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • N Offline
        N Offline
        nekitamtip
        wrote on 30 Jul 2018, 22:15 last edited by
        #3

        Thank you for your answer.

        Are you creating new threads regularly ?

        I'm not sure what is the regular way of creating threads so I'll give a short example at the end of the post to demonstrate the way I use threads.

        Are you creating files ? If so are you closing them properly ?

        I am not creating files.

        Is it a 32 bit application running in your 64 bit system ?

        I am running application on 64 bit system, but I'm not sure about the application. How can I check if a PySide application is 32 bit or 64 bit?

        On a side note, Qt 4 has reached end of life a long time ago and PySide 1 as well. If possible, you should consider updating to Qt 5 and PySide 2 which just got released.

        I will definitely consider updating application to Qt 5 and PySide 2, but it will take some time.

        Example code:

        import time
        import sys
        
        from PySide import QtGui, QtCore
        
        
        class ExampleThreadWorker(QtCore.QObject):
            start_work = QtCore.Signal()
            work_finished = QtCore.Signal()
        
            def __init__(self, worker_name, *args, **kwargs):
                super(ExampleThreadWorker, self).__init__(*args, **kwargs)
                self.worker_name = worker_name
                self.start_work.connect(self._do_some_work)
                self._thread = QtCore.QThread()
                self.moveToThread(self._thread)
                self._thread.start()
        
            def do_some_work(self, ):
                self.start_work.emit()
        
            def _do_some_work(self):
                time.sleep(5)
                print('Worker {} finished with work.'.format(self.worker_name))
                self.work_finished.emit()
        
        
        class MainWindow(QtGui.QWidget):
        
            def __init__(self, *args, **kwargs):
                super(MainWindow, self).__init__(*args, **kwargs)
        
                self.worker_1 = ExampleThreadWorker('Worker 1')
                self.worker_2 = ExampleThreadWorker('Worker 2')
                self.worker_3 = ExampleThreadWorker('Worker 3')
                self.worker_4 = ExampleThreadWorker('Worker 4')
                self.worker_5 = ExampleThreadWorker('Worker 5')
        
                self.worker_1.do_some_work()
                self.worker_2.do_some_work()
                self.worker_3.do_some_work()
                self.worker_4.do_some_work()
                self.worker_5.do_some_work()
        
        
        if __name__ == '__main__':
            app = QtGui.QApplication(sys.argv)
            window = MainWindow()
            window.show()
            sys.exit(app.exec_())
        
        
        J 1 Reply Last reply 31 Jul 2018, 04:30
        0
        • N nekitamtip
          30 Jul 2018, 22:15

          Thank you for your answer.

          Are you creating new threads regularly ?

          I'm not sure what is the regular way of creating threads so I'll give a short example at the end of the post to demonstrate the way I use threads.

          Are you creating files ? If so are you closing them properly ?

          I am not creating files.

          Is it a 32 bit application running in your 64 bit system ?

          I am running application on 64 bit system, but I'm not sure about the application. How can I check if a PySide application is 32 bit or 64 bit?

          On a side note, Qt 4 has reached end of life a long time ago and PySide 1 as well. If possible, you should consider updating to Qt 5 and PySide 2 which just got released.

          I will definitely consider updating application to Qt 5 and PySide 2, but it will take some time.

          Example code:

          import time
          import sys
          
          from PySide import QtGui, QtCore
          
          
          class ExampleThreadWorker(QtCore.QObject):
              start_work = QtCore.Signal()
              work_finished = QtCore.Signal()
          
              def __init__(self, worker_name, *args, **kwargs):
                  super(ExampleThreadWorker, self).__init__(*args, **kwargs)
                  self.worker_name = worker_name
                  self.start_work.connect(self._do_some_work)
                  self._thread = QtCore.QThread()
                  self.moveToThread(self._thread)
                  self._thread.start()
          
              def do_some_work(self, ):
                  self.start_work.emit()
          
              def _do_some_work(self):
                  time.sleep(5)
                  print('Worker {} finished with work.'.format(self.worker_name))
                  self.work_finished.emit()
          
          
          class MainWindow(QtGui.QWidget):
          
              def __init__(self, *args, **kwargs):
                  super(MainWindow, self).__init__(*args, **kwargs)
          
                  self.worker_1 = ExampleThreadWorker('Worker 1')
                  self.worker_2 = ExampleThreadWorker('Worker 2')
                  self.worker_3 = ExampleThreadWorker('Worker 3')
                  self.worker_4 = ExampleThreadWorker('Worker 4')
                  self.worker_5 = ExampleThreadWorker('Worker 5')
          
                  self.worker_1.do_some_work()
                  self.worker_2.do_some_work()
                  self.worker_3.do_some_work()
                  self.worker_4.do_some_work()
                  self.worker_5.do_some_work()
          
          
          if __name__ == '__main__':
              app = QtGui.QApplication(sys.argv)
              window = MainWindow()
              window.show()
              sys.exit(app.exec_())
          
          
          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 31 Jul 2018, 04:30 last edited by
          #4

          @nekitamtip said in Qt (PySide) application stops working after several days:

          I'm not sure what is the regular way

          I think what @SGaist means is: do you create threads again and again during life-cycle of your app?

          "How can I check if a PySide application is 32 bit or 64 bit" - you can check which Python is used (32/64 bit). You can check the Qt libraries packaged with PySide.

          I don't think it is a good idea if an object moves itself to another thread!

          self.moveToThread(self._thread)
          self._thread.start()
          

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4
          • N Offline
            N Offline
            nekitamtip
            wrote on 31 Jul 2018, 22:26 last edited by nekitamtip
            #5

            do you create threads again and again during life-cycle of your app?

            No, I create threads at the app init and then use them when needed. Also, I have checked Python and it is 64 bit.

            I don't think it is a good idea if an object moves itself to another thread!

            I will try moving moveToThread() and thread.start() methods outside of thread objects and see if an app works better after it.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 Aug 2018, 19:51 last edited by
              #6

              Depending on what your threads are doing, maybe QtConcurrent could be of interest.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              1/6

              29 Jul 2018, 11:36

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved