R. David Murray rdmur...@bitdance.com added the comment:
I still don't understand. I haven't used threading much, but I don't believe
I've ever used a static method with it.
--
___
Python tracker rep...@bugs.python.org
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
Roy, it's not clear what you're after. What is it that you think is special
about the way the target is called?
--
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
Roy Smith r...@panix.com added the comment:
Here's the code I ended up writing:
class Foo():
def __init__(self):
self.thread = Thread(target=Foo.runner, args=[self])
self.thread.start()
@staticmethod
def runner(self):
# blah, blah, blah
It was not immediately
Brian Curtin cur...@acm.org added the comment:
It was not immediately clear from the documentation if my runner() method
should be declared static or not.
The doc doesn't mention static methods at all, and my uses and others that I've
seen have never used static methods.
--
nosy:
Antoine Pitrou pit...@free.fr added the comment:
You don't have to use any staticmethod here (actually, staticmethod is an
anti-pattern in Python). Just write:
class Foo():
def __init__(self):
self.thread = Thread(target=self.runner)
self.thread.start()
def runner(self):
New submission from Roy Smith r...@panix.com:
The documentation for the threading.Thread constructor says:
target is the callable object to be invoked by the run() method. Defaults to
None, meaning nothing is called.
This could be improved by explicitly stating that target is called in a
R. David Murray rdmur...@bitdance.com added the comment:
I have no idea what a static context means, so it wouldn't make it any
clearer to me. Can you explain further what your confusion is?
--
nosy: +r.david.murray
type: - feature request
versions: +Python 2.7, Python 3.1, Python
Roy Smith r...@panix.com added the comment:
What I meant was whether target should be declared as @staticmethod or not.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11073
___