Python Forum
How to Kill Dead Loop of "while"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Kill Dead Loop of "while"
#3
(Aug-22-2019, 04:40 AM)cheers100 Wrote: Hello,

I'm a very beginner of Python. I teach myself Python with videos.

My question is I write an dead loop of while. How should I stop the programme running crazily?

The instructor in the videos say,"for such a case, I should just use "ctrl + c" or go to task manager and select the programme, so I can stop the programme of "while" of loop.

However it didn't work at all with the two ways.

-ctrl +c nothing happen
-task manager: I select the programme, but I fail to kill the programme. The programme is just keeping opening mp3 one after another.

Finally I have to shut down the computer to stop the programme.

The following is the codes I write for your reference only, I don't request you to correct my codes, and other people have to point out that I need to use sleep(), and i = i +1 , etc.


import os

i = 1
while i < 8 :

 fname = 'd:/1/1' + str(i) + '.mp3'

 os.system(fname)
My OS is Windows 7


I tried your script on Windows 10 machine and am abler to stop it with Ctrl+C key combinations
Output:
The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. The system cannot find the path specified. Traceback (most recent call last): File "deadwhile.py", line 8, in <module> os.system(fname) KeyboardInterrupt
Reply


Messages In This Thread
How to Kill Dead Loop of "while" - by cheers100 - Aug-22-2019, 04:40 AM
RE: How to Kill Dead Loop of "while" - by Aravind_K - Aug-22-2019, 04:46 AM
RE: How to Kill Dead Loop of "while" - by Malt - Aug-22-2019, 04:50 AM
RE: How to Kill Dead Loop of "while" - by DeaD_EyE - Aug-22-2019, 07:20 AM
RE: How to Kill Dead Loop of "while" - by cheers100 - Aug-22-2019, 09:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  os.kill elstolbo 1 2,448 Jan-26-2020, 04:13 PM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020