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


Groups > comp.lang.python > #77777

Re: Thread-ID - how much could be?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'finished,': 0.07; 'derived': 0.09; 'item,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'template': 0.14; 'thread': 0.14; 'daemon,': 0.16; 'long-time': 0.16; 'name=none,': 0.16; 'number?': 0.16; 'peak': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Thread': 0.16; 'threads.': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'helper': 0.24; 'looks': 0.24; 'question': 0.24; "i've": 0.25; 'class.': 0.26; 'header:X -Complaints-To:1': 0.27; 'function': 0.29; "i'm": 0.30; 'exceptions': 0.31; 'allows': 0.31; 'class': 0.32; 'run': 0.32; 'running': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'there': 0.35; 'joined': 0.36; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'that,': 0.38; 'skip:_ 30': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'eventually': 0.60; 'new': 0.61; 'name': 0.63; 'maximum': 0.63; 'reached': 0.63; 'limit': 0.70; 'upper': 0.74; ':).': 0.84; 'again?': 0.84; 'subject:much': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Thread-ID - how much could be?
Date Thu, 11 Sep 2014 21:48:18 +0200
Organization None
References <20140911193018.GA24416@arxnet.hu>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Gmane-NNTP-Posting-Host p57bd9cbc.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13941.1410464914.18130.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410464914 news.xs4all.nl 2841 [2001:888:2000:d::a6]:54180
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77777

Show key headers only | 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