Shan-Desai Shan-Desai - 5 months ago 12
Python Question

Can a Thread not be daemonized in python3.2?

I am running a script in python-3.2 on a Raspberry Pi 2 Model B

The thread looks like this:

myThread = threading.Thread(target=someFunction, args=(arg1,arg2,arg3),
daemon=True)
myThread.start()


Everytime this thread gets called. this error gets triggered:

TypeError: __init__() got an unexpected keyword argument 'daemon'


I know that there is not Python-3.4 stable version for the Debian Wheezy Version 7.10 hence I have to work around with python 3.2

Ironically, the Python 3.2 Documentation does state that
daemon
is a boolean available.

What is this glitch and how can I solve this?

Answer

The daemon argument was added in version 3.3, see. Setting the flag in prior versions works like this:

myThread = threading.Thread(target=someFunction, args=(arg1,arg2,arg3))
myThread.daemon = True
myThread.start()