classification
Title: Python 3.3 - Slowing down computer
Type: performance Stage: resolved
Components: Windows Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: David.Edelsohn, Ramchandra Apte, jon_irenicus, mrabarnett, pitrou
Priority: normal Keywords:

Created on 2013-06-22 19:14 by jon_irenicus, last changed 2013-07-03 13:57 by pitrou. This issue is now closed.

Messages (8)
msg191661 - (view) Author: Jon Irenicus (jon_irenicus) Date: 2013-06-22 19:14
Python's really slowing my computer down.
After running my script, the computer grinds to a halt and it's performance drops.
Even after a reboot, the problem still persists.
msg191662 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-06-22 19:18
You're not giving enough information to help us make sense of your problem. If you don't know how to describe the problem precisely, you should try the mailing-list: http://mail.python.org/mailman/listinfo/python-list
msg191664 - (view) Author: Jon Irenicus (jon_irenicus) Date: 2013-06-22 19:32
The problem is when i run my python script, it somehow slows the whole computer down.
I checked my cpu usage, ram usage and disk usage, but nothing comes up.
The script isn't big, it's only about 10kb big.
msg191666 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-06-22 19:37
We can't make anything useful of such a bug report. At a minimum, please post your entire script and explain how you are running it. Also explain what your system configuration is (operating system, etc.).

That said, it's highly unlikely that Python is responsible for slowing your computer down *after* it has finished running.
msg191672 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-06-22 20:49
Is the script changing any configuration settings in your system that reduces available system resources without occupying CPU, RAM or disk?
msg191673 - (view) Author: Jon Irenicus (jon_irenicus) Date: 2013-06-22 20:56
#David Edelsohn
It's not changing anything.


with open('url_list.txt') as f:
    content = f.readlines()
    content = ''.join(content)
    content = list(content)
    if content[0] == 'h' and content[1] == 't' and content[2] =='t':
        print("Make sure that you remove http:/ !")
        time.sleep(1)
        sys.exit("")
    elif content[0] != 'w' and content[1] != 'w' and content[2] != 'w':
        print("Make sure that you have the www. at the start!")
        print(content[0],content[1])
        time.sleep(1)
        sys.exit("")
        os.system("CLS")
    else:
        print("Configuration looks fine!")
        time.sleep(1)
        with open('url_list.txt') as f:
            content_url = f.readlines()
            content_join = ''.join(content_url)
            print("You will load video url",content_join,".")
            time.sleep(1)
            os.system("CLS")
            print("Processing...")
            time.sleep(1)
        

global x
x = 0
time.sleep(1)
if x > 35:
    print("Warning! Your computer could go unstable!")
    time.sleep(1)
    os.system("CLS")
    print("Are you sure you want to select that many? - yes - no")
    while "1" == "1":
        _answer_ = input("|yes| |no| - ")
        if _answer == "yes":
            break
        elif answer == "no":
            sys.exit("Quitting application")
        else:
            print("Invalid input!")
            time.sleep(1)
            os.system("CLS")
    
elif x in range(1,35):
    print("Seems fine")
elif x < 0:
    print("Warning!")
    print("Out of range value!")
    os.system("CLS")
    time.sleep(5)
    sys.exit("")
os.system("CLS")
time.sleep(5)
print("Starting now!")
while x > 0:
    x = x - 1
    os.system("start "+content_join)

time.sleep(10)
os.system("taskkill /f /im chrome.exe")
os.system("start test.py")
sys.exit("restarting")
msg192218 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2013-07-02 22:02
> with open('url_list.txt') as f:
>
>     content = f.readlines()
>     content = ''.join(content)
>
Why are you reading all of the lines and then joining them together like that? Why not just do:

    content = f.read()

>     content = list(content)

Why are you making a list? You could just as easily index the string.

>     if content[0] == 'h' and content[1] == 't' and content[2] =='t':

If 'content' is a string, then that can be:

      if content.startswith('htt'):

>         print("Make sure that you remove http:/ !")
>         time.sleep(1)
>         sys.exit("")
>     elif content[0] != 'w' and content[1] != 'w' and content[2] != 'w':

If 'content' is a string, then that can be:

      elif content.startswith('www'):

>         print("Make sure that you have the www. at the start!")
>         print(content[0],content[1])
>         time.sleep(1)
>         sys.exit("")
>         os.system("CLS")
>     else:
>         print("Configuration looks fine!")
>         time.sleep(1)
>         with open('url_list.txt') as f:

Now you're reading it for a second time!

>             content_url = f.readlines()
>             content_join = ''.join(content_url)
>             print("You will load video url",content_join,".")
>             time.sleep(1)
>             os.system("CLS")
>             print("Processing...")
>             time.sleep(1)
>
>
> global x

'global' has no effect outside a function.

> x = 0
> time.sleep(1)
> if x > 35:
>     print("Warning! Your computer could go unstable!")
>     time.sleep(1)
>     os.system("CLS")
>     print("Are you sure you want to select that many? - yes - no")
>     while "1" == "1":

Or:
      while True:

>         _answer_ = input("|yes| |no| - ")
>         if _answer == "yes":
>             break
>         elif answer == "no":

You have '_answer_', '_answer' and 'answer'.

>             sys.exit("Quitting application")
>         else:
>             print("Invalid input!")
>             time.sleep(1)
>             os.system("CLS")
>
> elif x in range(1,35):

Or:

  elif 1 <= x <= 35:

>     print("Seems fine")
> elif x < 0:
>     print("Warning!")
>     print("Out of range value!")
>     os.system("CLS")
>     time.sleep(5)
>     sys.exit("")
> os.system("CLS")
> time.sleep(5)
> print("Starting now!")
> while x > 0:
>     x = x - 1
>     os.system("start "+content_join)

You're starting up to 35 processes (or possibly more). That's going to slow down your machine.

>
> time.sleep(10)
> os.system("taskkill /f /im chrome.exe")
> os.system("start test.py")

Now you're repeating the whole procedure (I think). That's going to slow down your machine even more.

> sys.exit("restarting")

So it looks like your problem is not the fault of Python itself, but due to what you're doing with it.
msg192236 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-07-03 12:44
The problem is with OP's code; not Python. Please close this bug as invalid. OP can ask on the Python mailing list to fix his code.
History
Date User Action Args
2013-07-03 13:57:27pitrousetstatus: open -> closed
resolution: not a bug
stage: resolved
2013-07-03 12:44:53Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg192236
2013-07-02 22:02:02mrabarnettsetnosy: + mrabarnett
messages: + msg192218
2013-06-22 20:56:34jon_irenicussetmessages: + msg191673
2013-06-22 20:49:22David.Edelsohnsetnosy: + David.Edelsohn
messages: + msg191672
2013-06-22 19:37:21pitrousetmessages: + msg191666
2013-06-22 19:32:10jon_irenicussetstatus: pending -> open

messages: + msg191664
2013-06-22 19:18:31pitrousetstatus: open -> pending
nosy: + pitrou
messages: + msg191662

2013-06-22 19:14:48jon_irenicuscreate