Does Python's garbage collector harm my application?

Is it bad in Python, when I don't hold a reference of a Thread I created with: threading.Thread(target=worker_method)? Is it possible that the garbage collecor does anything to it, which affects the stability of my application?

Answers


The thread will keep running regardless, but the downside is that you don't have a handle to the thread any more in order to communicate with it.

A simple test shows that even when the thread object goes out of scope, its still running:

from threading import Thread
from time import sleep

def t_func():
    print "Sleeping"
    sleep(5)
    print "Done Sleeping"

def test():
    t = Thread(target=t_func)
    t.start()

>>> test()
Sleeping
Done Sleeping

Even if you were to delete the t thread object right after starting it, it will keep running. But you really should be keeping track of thread that you start, to make sure they finish or to monitor if they are alive. And also, to shut them down cleanly if need be.


Need Your Help

Http live streaming to iphone

iphone objective-c ios http http-live-streaming

I'm trying to play an http live stream to iphone, it looks like i have looked every example, mistakes and everything that i could found on the internet and apple docs about http live stream, and i ...

SELECT TableName.Col1 VS SELECT Col1

mysql select

This might be a weird question but didnt know how to research on it. When doing the following query:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.