subclassing Thread and start

Gonçalo Rodrigues op73418 at
Fri Jun 20 17:23:16 CEST 2003

I have the following problem:

In order to simplify managing Thread's, I want my (derived) Thread's
to do two things when they start running: return their thread id to
the thread that started them, and set an attribute, e.g., to
the Thread id.

Looking at the threading module code, this involves adding the
following simple things:

1. Add the following to the start method:

id = thread.start_new_thread(self.__bootstrap, ())
return id

2. Add the following to the __bootstrap private method: = thread.get_ident()

But in the docs, it says explicitely that when subclassing I should
not override start, so what do you suggest? If I go ahead and override
it, to what should I be on the lookout? Any other ideas on
accomplishing what I need *not involving* overriding the start method?

Hoping to have made myself understood, TIA, with my best regards,
G. Rodrigues

P.S: Up to now I have used the threading module patched with the above
-- a solution i *do not like* for obvious reasons.

More information about the Python-list mailing list