Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Signal slow for the first few times. (Pyqt5)
Forum Updated to NodeBB v4.3 + New Features

Signal slow for the first few times. (Pyqt5)

Scheduled Pinned Locked Moved Unsolved Qt for Python
13 Posts 4 Posters 1.3k Views 3 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.
  • SGaistS SGaist

    Hi,

    This does sound strange.

    Which version of PyQt5 are you using ?
    On which OS ?
    With which version of Python ?

    I Offline
    I Offline
    Igor86
    wrote on last edited by
    #4

    @SGaist

    i Just tried with Python 3.10.10 and pyqt5 5.15.10

    same problem..

    JonBJ 1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #5

      PyQt's slot decorator is documented as reducing the amount of memory used and is slightly faster. I haven't attempted to verify the statement, but it looks like a cheap experiment to try.

      Another experiment is to "prime" the worker thread by sending an unrelated signal to determine if the delay is related to the thread, the worker object, or the particular slot.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      I 1 Reply Last reply
      1
      • I Igor86

        @SGaist

        i Just tried with Python 3.10.10 and pyqt5 5.15.10

        same problem..

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #6

        @Igor86
        I agree with both of @jeremy_k's points to try.

        Also, would you be prepared to give it a quick go using PySide2 (equivalent to PyQt5, so not PySide6 which is PyQt6)? Usually there is barely anything to change. If by chance PySide2 does not behave like this it would indicate a PyQt5 issue.

        I 1 Reply Last reply
        0
        • JonBJ JonB

          @Igor86
          I agree with both of @jeremy_k's points to try.

          Also, would you be prepared to give it a quick go using PySide2 (equivalent to PyQt5, so not PySide6 which is PyQt6)? Usually there is barely anything to change. If by chance PySide2 does not behave like this it would indicate a PyQt5 issue.

          I Offline
          I Offline
          Igor86
          wrote on last edited by
          #7

          @JonB thank you, i am trying the pyside option you posted, but i am having difficulties as i am getting this error: cannot import name 'uic' from 'PySide2'

          any idea on what i have to do in this case? i am an occasional python progger and not experienced at all.. thank you

          JonBJ 1 Reply Last reply
          0
          • I Igor86

            @JonB thank you, i am trying the pyside option you posted, but i am having difficulties as i am getting this error: cannot import name 'uic' from 'PySide2'

            any idea on what i have to do in this case? i am an occasional python progger and not experienced at all.. thank you

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #8

            @Igor86 said in Signal slow for the first few times. (Pyqt5):

            cannot import name 'uic' from 'PySide2'

            Unfortunately that is to do with the one major difference between PyQt and PySide if you are using .ui file from Designer. I can't remember what you have to change, easy for you if you are a programmer but not if not and I don't use PyQt/PySide regularly to tell you, so you may have to leave this test. Unless a Python person wants to tell you what to alter....

            1 Reply Last reply
            0
            • jeremy_kJ jeremy_k

              PyQt's slot decorator is documented as reducing the amount of memory used and is slightly faster. I haven't attempted to verify the statement, but it looks like a cheap experiment to try.

              Another experiment is to "prime" the worker thread by sending an unrelated signal to determine if the delay is related to the thread, the worker object, or the particular slot.

              I Offline
              I Offline
              Igor86
              wrote on last edited by
              #9

              @jeremy_k @JonB the problem was solved by adding the @pyqtSlot decorator.

              Thank you very much for your help!

              jeremy_kJ JonBJ 2 Replies Last reply
              2
              • I Igor86

                @jeremy_k @JonB the problem was solved by adding the @pyqtSlot decorator.

                Thank you very much for your help!

                jeremy_kJ Offline
                jeremy_kJ Offline
                jeremy_k
                wrote on last edited by
                #10

                @Igor86 Thanks for running and reporting on the experiment.

                Asking a question about code? http://eel.is/iso-c++/testcase/

                1 Reply Last reply
                0
                • I Igor86

                  @jeremy_k @JonB the problem was solved by adding the @pyqtSlot decorator.

                  Thank you very much for your help!

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #11

                  @Igor86
                  Glad that sorted you out. I nearly suggested @pyqtslot but could not see from the description why that would make such an initial difference of several seconds, and still wonder now why that should be, but there you are.

                  I 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @Igor86
                    Glad that sorted you out. I nearly suggested @pyqtslot but could not see from the description why that would make such an initial difference of several seconds, and still wonder now why that should be, but there you are.

                    I Offline
                    I Offline
                    Igor86
                    wrote on last edited by
                    #12

                    @JonB it looks like the problem is here again. but it was indeed away yesterday when i tested it several times.. the only differenche is that now i have enabled the hard disk lock in windows. so am going to investigate if that makes a difference.

                    JonBJ 1 Reply Last reply
                    0
                    • I Igor86

                      @JonB it looks like the problem is here again. but it was indeed away yesterday when i tested it several times.. the only differenche is that now i have enabled the hard disk lock in windows. so am going to investigate if that makes a difference.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #13

                      @Igor86
                      Hmmm. I hope @pyqtslot does somehow work for you, just I wonder how it could possibly make a difference of seconds in your situation. I would wonder whether something else might be going on, as you say to do with first time reboot. In your output there is Got Crate ID between the emission and the receipt, so something else is going on in your code other than what you have shown?

                      "between 3 and 6 seconds" is an enormous delay in computer terms. I find it hard to believe that whatever @pyqtslot does it could cost so much without it. If, say, https://stackoverflow.com/a/45842186/489865 or https://stackoverflow.com/a/40330912/489865 or https://www.codeproject.com/Articles/1123088/PyQt-signal-slot-connection-performance are right in their description I can't see how it would achieve that. To me it sounds more like: the slot will only print its output once the processor switches from the worker thread back to the main thread. If something on your system is "very busy" (hardware? memory paging?), first time after reboot, the OS may be unable to do that in a timely manner?

                      1 Reply Last reply
                      0

                      • Login

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