PY3.W1506

Bad thread instantiation

The warning is emitted when a threading.Thread class is instantiated without the target function being passed. By default, the first parameter is the group param, not the target param.

Noncompliant Code:

Copy
import threading
def thread_target(n):
    print(n ** 2)
thread = threading.Thread(thread_target, args=(10,))
thread.start()

Compliant Code:

Copy
import threading
def thread_target(n):
    print(n ** 2)
thread = threading.Thread(target=thread_target, args=(10,))
thread.start()

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.