My python threads seem to freeze raspberry pi
<p>I wrote this python code to run continuously on my raspberry pi with Raspian by:
' nohup python code.py &amp; '</p>

<p>It works like intended for a while (anything from 5 mins to 60), then seems to freeze my pi (I have not connected a monitor yet, but it kills the remote connection and the green on-LED stops), 
There should not start more then maybe 6 threads at once as they finish, but it might still overload.</p>

<p>My question is, am I doing something wrong or could I optimize it for performance?</p>

<p>And it writes a HUGE amount of text to the "nohup-document", can this cause problems?</p>

<pre><code>#This downloads the link using "youtube-dl"
def Download(link):
    command = "youtube-dl " + link
    call(command.split(), shell=False)

#This check if the link exist in document, else writes it to the document and start downloading it
def CheckAndDL2(DLlink):
    if not DLlink in open('usedlinks.txt').read():
        f = open('usedlinks.txt', 'a')
        f.write(DLlink + "\n")
        f.close()
        try:
            thread.start_new_thread(Download, (DLlink,))
        except:
            print("unable to start thread1")

while 1:
    #getLinks will update links[] with new urls 
    getLinks(myurl) 
    CheckAndDL2(links[1])
    time.sleep(10)
    CheckAndDL2(links[2])
    time.sleep(10)
    CheckAndDL2(links[3])
    print('Loop done')
    links = []
    time.sleep(120)
</code></pre>

<p>Stupid me! I was using a <strong>powersupply</strong> with a current output at 0.45mA. I changed to 1A and no problems since!</p>

python multithreading raspberry-pi nohup youtube-dl