Python Forum
Threading timer crashes my App
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threading timer crashes my App
#2
A windowed application has an "event loop". Conceptually it polls a queue of events (mouse and keyboard, mostly), processes the event, and then polls for the next event. A good deal of the events is processed by the UI support (the Qt library, in your case), but some are forwarded to your app (_set_alarm_btn_clicked). If your code doesn't return quickly, the event loop gets stuck, doesn't poll further events, so you application no longer reacts to events and your UI freezes.

So you have to wonder what happens when you call  clock.run()....

In practice, any code that takes a significant amount of time (>.1 second) should be delegated to a thread. That thread then communicates with the event loop thread by sending it events. Not a PyQt expert, but this looks like the answer.

PS: future-proofing: have you checked that you can use pygame and pyqt4 in the same application without getting conflicts?
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Threading timer crashes my App - by panoss - Jun-03-2017, 08:30 AM
RE: Threading timer crashes my App - by Ofnuts - Jun-04-2017, 12:17 PM
RE: Threading timer crashes my App - by metulburr - Jun-04-2017, 05:32 PM
RE: Threading timer crashes my App - by panoss - Jun-05-2017, 03:42 PM
RE: Threading timer crashes my App - by nilamo - Jun-05-2017, 05:57 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Concurrent futures threading running at same speed as non-threading billykid999 13 1,935 May-03-2023, 08:22 AM
Last Post: billykid999
  Understanding and debugging memory error crashes with python3.10.10 Arkaik 5 2,187 Apr-18-2023, 03:22 AM
Last Post: Larz60+
  using threading.Timer for function korenron 1 1,239 Dec-20-2022, 01:09 PM
Last Post: ndc85430
  Pydroid3 app crashes on xiaomi poco F3 JMD 2 1,299 Nov-27-2022, 11:56 AM
Last Post: JMD
  HTML file crashes program mikefirth 12 3,945 Dec-31-2021, 03:57 AM
Last Post: Pedroski55
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,158 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Scraping a Flexible Element - works at first, and then crashes JonnyB 0 1,538 Aug-14-2021, 07:25 PM
Last Post: JonnyB
  email timer/rss feed timer ndiniz 1 2,113 Feb-02-2021, 07:18 PM
Last Post: nilamo
  Bug that crashes the Python interpreter 3.7 on Mac OS X Stef 1 3,729 Feb-18-2019, 06:30 PM
Last Post: micseydel
  code keeps running if i use from threading import timer? birddseedd 3 2,642 Jan-25-2019, 05:00 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020