threading id generator ?

Alan Kennedy alanmk at
Thu Feb 19 15:52:00 CET 2004

[Andrea Manzini]
 > I'm a python newbie with a little problem; my need is to share an
 > incrementing counter between threads; i.e. every time I create a
 > new thread (which handle a single tcp/ip connection), I must assign
 > an unique numeric ID to it, without reuse old numbers... In example:
 > thread-1 id: 1
 > thread-2 id: 2
 > thread-3 id: 3
 > thread-100 id: 100
 > thread-n id: n
 > which locking semantic I must use to implement a shared generator
 > in a thread ?

This came up about a month ago. Group-Googling for ("shared generator"
and "multiple threads") gives useful results.*


alan kennedy
check http headers here:
email alan:    

More information about the Python-list mailing list