This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author roysmith
Recipients docs@python, r.david.murray, rhettinger, roysmith
Date 2011-01-31.13:19:14
SpamBayes Score 1.8993181e-07
Marked as misclassified No
Message-id <1296479955.54.0.0108216353033.issue11073@psf.upfronthosting.co.za>
In-reply-to
Content
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 clear from the documentation if my runner() method should be declared static or not.  In retrospect, it must be (since this can be used with target functions which are not class methods at all), but it took a bit of thought to get from what the documentation said (i.e. 'callable object to be invoked by the run() method') to that conclusion.  

It seems to me the documentation could be a bit more explicit that your target does not get called as a method of some object.  Changing the text to read, "static function or other callable object" would remove any such confusion.

It could be that some of my confusion is due to my previously working with a C++ threading package where the thread runner functions *were* class methods.  Still, it seems like the potential for other people to be similarly confused exists and a little tweaking of the documentation text would help.
History
Date User Action Args
2011-01-31 13:19:15roysmithsetrecipients: + roysmith, rhettinger, r.david.murray, docs@python
2011-01-31 13:19:15roysmithsetmessageid: <1296479955.54.0.0108216353033.issue11073@psf.upfronthosting.co.za>
2011-01-31 13:19:14roysmithlinkissue11073 messages
2011-01-31 13:19:14roysmithcreate