Code Feedback
Peter Hansen
peter at engcorp.com
Mon Feb 6 17:21:29 EST 2006
Dan M wrote:
>>2) Anybody know how to alter the "while 1: pass" section to make the
>>app stoppable?
>
>
> That one I think I can help with! See below.
>
>
>> while 1: pass
>
>
> try:
> while 1:
> pass
> except KeyboardInterrupt:
> break
That might make it "stoppable" (or at least more cleanly stoppable than
it is now) but it doesn't make it efficient.
Adding something like "time.sleep(0.1)" in place of "pass" is
advisable... or the main thread will be "busy-waiting", using up CPU
time, while waiting for Ctrl-C...
-Peter
More information about the Python-list
mailing list