Exception raised in wrong thread?

Discussion in 'Python' started by pegazik, Sep 19, 2005.

  1. pegazik

    pegazik Guest

    Hello.

    I have problem and I'm looking for help. Probably there is some quite
    easy solution, but I can't see it.

    I'm trying to perform some action that have to be timeout safe. So here
    is the structure of my program:

    \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    def TimeoutHandler():
    print '!'
    raise Exception

    class Active:
    def Action:
    timer = Timer(1, TimeoutHandler)
    print '1'
    timer.start()
    try:
    print '2'
    time.sleep(20)
    print '3'
    except:
    print '4'
    else:
    print '5'
    timer.cancel()
    print '6'

    active = Actice()

    ///////////////////////////////////////////
    The output is:
    12!356

    My question is, why exception is not raised correctly? Could be the
    reason that (probably) timer is another thread and there is no
    exception in the main thread? How to solve this problem? [My timeout
    should be smaller than one second so I can't use signal.alarm()]

    Thanks for your reply,
    Krzysztof Nowak
    pegazik, Sep 19, 2005
    #1
    1. Advertising

  2. Please don't post the same question twice with different subjects.
    --
    Piet van Oostrum <>
    URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
    Private email:
    Piet van Oostrum, Sep 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlos
    Replies:
    1
    Views:
    359
    Wilco Bauwer
    Feb 17, 2005
  2. Joe Wong
    Replies:
    1
    Views:
    458
    Ype Kingma
    May 14, 2004
  3. Lonnie Princehouse
    Replies:
    8
    Views:
    536
    Lonnie Princehouse
    Oct 2, 2004
  4. dcrespo
    Replies:
    28
    Views:
    860
    dcrespo
    Oct 22, 2005
  5. Ziliang Chen
    Replies:
    3
    Views:
    149
    Ziliang Chen
    Feb 22, 2013
Loading...

Share This Page