Related To Threads

Discussion in 'Python' started by Sidd, Aug 21, 2005.

  1. Sidd

    Sidd Guest

    Hello,
    I want to write a thread in python which can be invoked for say 5
    sec, within that the threads function would be to take input,is it
    possible because i tried it and found that raw_input() is blocking
    threads.
    Sidd, Aug 21, 2005
    #1
    1. Advertising

  2. Sidd

    Steve Holden Guest

    Sidd wrote:
    > Hello,
    > I want to write a thread in python which can be invoked for say 5
    > sec, within that the threads function would be to take input,is it
    > possible because i tried it and found that raw_input() is blocking
    > threads.
    >

    There isn't really a convenient solution to this problem, since a thread
    can't easily be stopped "from the outside".

    Various solutions you might dream up using signals are likely to be
    either unreliable or non-portable or possibly both.

    You m ay have to poll the keyboard directly to gather input and time out
    if it doesn't arrive.

    http://www.python.org/doc/faq/windows.html#how-do-i-check-for-a-keypress-without-blocking

    will be some help in the windows environment, select() is your friend
    under *nix.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC http://www.holdenweb.com/
    Steve Holden, Aug 21, 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. Maxwell Hammer
    Replies:
    7
    Views:
    630
    Peter Hansen
    Jun 18, 2005
  2. yoda
    Replies:
    2
    Views:
    415
    =?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=
    Aug 1, 2005
  3. threads without threads

    , Aug 27, 2004, in forum: C Programming
    Replies:
    4
    Views:
    379
    William Ahern
    Aug 27, 2004
  4. Pedro Pinto

    Java Threads - Get running threads

    Pedro Pinto, Apr 8, 2008, in forum: Java
    Replies:
    2
    Views:
    1,398
    Arne Vajhøj
    Apr 9, 2008
  5. Une bévue
    Replies:
    0
    Views:
    130
    Une bévue
    Jun 14, 2006
Loading...

Share This Page