Timer hangs when quitting app

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gitte Wange

    #1

    Timer hangs when quitting app

    Hello,

    I'm trying to create an application that needs a Timer() to do various
    checks.
    My class has a self.timer = Timer(900, self.sendDNSReq uest)
    The timer itself works fine but whenever I try to exit the application, it
    simply hangs and I have to kill the proces using `kill pid`

    I have tried uncommenting the timer stuff, and then the app works as
    expected.

    Is there anything I need to do to kill the timer?
    I have tried to create a __del__(self) function in my app. It gets called
    when I leave out the timer, but with the timer enabled, it never gets
    called.

    Any hint will be appreciated :-)

    Greetings,
    Gitte Wange
  • Peter Hansen

    #2
    Re: Timer hangs when quitting app

    Gitte Wange wrote:[color=blue]
    > I'm trying to create an application that needs a Timer() to do various
    > checks.
    > My class has a self.timer = Timer(900, self.sendDNSReq uest)
    > The timer itself works fine but whenever I try to exit the application, it
    > simply hangs and I have to kill the proces using `kill pid`
    >
    > I have tried uncommenting the timer stuff, and then the app works as
    > expected.
    >
    > Is there anything I need to do to kill the timer?
    > I have tried to create a __del__(self) function in my app. It gets called
    > when I leave out the timer, but with the timer enabled, it never gets
    > called.[/color]

    A Timer is a subclass of threading.Threa d, which means
    you can do "self.timer.set Daemon(True)" on it *before*
    you start it, and it will not hang the app when it
    is trying to exit.

    See notes in the threading module's Thread.setDaemo n
    docs for background.

    -Peter

    Comment

    Working...