469,306 Members | 2,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Related To Threads

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.

Aug 21 '05 #1
1 1631
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/

Aug 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Maxwell Hammer | last post: by
10 posts views Thread by Darian | last post: by
reply views Thread by archana | last post: by
2 posts views Thread by archana | last post: by
2 posts views Thread by Water Cooler v2 | last post: by
7 posts views Thread by Louis B. (ldb) | last post: by
reply views Thread by =?UTF-8?B?TmlscyBPbGl2ZXIgS3LDtmdlcg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.