subclassing Thread and start
op73418 at mail.telepac.pt
Mon Jun 23 16:41:04 CEST 2003
On Sun, 22 Jun 2003 14:39:24 GMT, "Steve Holden"
<sholden at holdenweb.com> wrote:
>Note that the threading module is the one you should use for threads in your
>program, the thread module is rather lower-level and therefore rather more
>Your MyThread class could look like this"
> class MyThread(threading.Thread):
> def start(self):
> self.id = id(self)
But it is right here that the gist is. I do not want id(self) but the
id returned by the underlying low level thread wrapped by
> return self.id
>If you *must* use the thread module, remember that although the
>documentation says that you shouldn't *override* start(), that doesn't mean
>you can't *extend* it. So, similar to the example aboce, you should make
>sure that your thread's start_new_thread() method calls the base class'
>start_net_thread() before running any of its own code.
>As a general rule, you should try not to assume any knowedge of the insides
>of the class you are using. Hope this helps.
It does, thanks. In particular, it is making aware that I am making
things more complicated for myself by insisting on having the id
returned by the low level thread. Need to think more on this.
With my best regards,
More information about the Python-list