Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Related To Threads

Reply
Thread Tools

Related To Threads

 
 
Sidd
Guest
Posts: n/a
 
      08-21-2005
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.

 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      08-21-2005
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/window...thout-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/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How should multiple (related) projects be arranged (structured) and configured so that they can share code, have a related package structure and enable proper unittesting, and ensuring no namespace collisions ToddLMorgan@gmail.com Python 14 04-21-2006 04:03 PM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
How should threads be terminated? (related to 'Help with thread related tracebacks') Maxwell Hammer Python 7 06-18-2005 04:20 PM
threads without threads sindica@gmail.com C Programming 4 08-27-2004 09:25 PM



Advertisments