Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #77777

Re: Thread-ID - how much could be?

From Peter Otten <__peter__@web.de>
Subject Re: Thread-ID - how much could be?
Date 2014-09-11 21:48 +0200
Organization None
References <20140911193018.GA24416@arxnet.hu>
Newsgroups comp.lang.python
Message-ID <mailman.13941.1410464914.18130.python-list@python.org> (permalink)

Show all headers | View raw


Ervin Hegedüs wrote:

> I've made a long-time running daemon, which uses threads. Looks
> like that works perfectly, now I'm looking at the exceptions :).
> 
> In the log, I found an interesting message:
> 
> Exception in thread Thread-82:
> ...
> 
> The main function allows 2 thread to run simultaniously, and if
> the thread finished, then it joined with th.join(), where the
> "th" is the thread item, derived from threading.Thread class.
> 
> My question is: how much thread ID could be totally? Is there any
> maximum number? And if the thread reached that, what will be
> done? Overlflowed? Couting from 0 again?

A quick peak into threading.py reveals

# Helper to generate new thread names
_counter = 0
def _newname(template="Thread-%d"):
    global _counter
    _counter += 1
    return template % _counter

class Thread:
    ...
    def __init__(self, group=None, target=None, name=None,
                 args=(), kwargs=None, *, daemon=None):
        ...
        self._name = str(name or _newname())


There is no upper limit to the thread name other than that you will 
eventually run out of memory ;)

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Thread-ID - how much could be? Peter Otten <__peter__@web.de> - 2014-09-11 21:48 +0200

csiph-web