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


Groups > comp.lang.python > #77781

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.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'sys': 0.07; 'means,': 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; '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; 'exception': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'memory': 0.22; 'import': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'helper': 0.24; 'question': 0.24; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; '>>>>': 0.31; 'sep': 0.31; 'class': 0.32; 'run': 0.32; 'skip:_ 10': 0.34; 'could': 0.34; 'there': 0.35; '+0200,': 0.36; 'thanks': 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; 'hope': 0.61; 'new': 0.61; 'name': 0.63; 'maximum': 0.63; 'reached': 0.63; 'it!': 0.67; 'limit': 0.70; 'upper': 0.74; 'again?': 0.84; 'otten': 0.84; 'peter,': 0.84; 'subject:much': 0.91; 'system:': 0.91; 'reply,': 0.93
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 Fri, 12 Sep 2014 00:02:50 +0200
Organization None
References <20140911193018.GA24416@arxnet.hu> <lusua3$a4t$1@ger.gmane.org> <20140911213229.GC26465@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.13945.1410472988.18130.python-list@python.org> (permalink)
Lines 67
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1410472988 news.xs4all.nl 2873 [2001:888:2000:d::a6]:55204
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:77781

Show key headers only | View raw


Ervin Hegedüs wrote:

> Hi Peter,
> 
> thanks for the reply,
> 
> On Thu, Sep 11, 2014 at 09:48:18PM +0200, Peter Otten wrote:
>> Ervin Hegedüs wrote:
>> 
>> > Exception in thread Thread-82:
>> > ...
>> > 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 ;)
> 
> thanks - I hope that the memory will not run out by these
> threads... :)
> 
> Anyway, that means, on my system:
> 
>>>> import sys
>>>> print sys.maxint
> 9223372036854775807
> 
> the couter could be 9223372036854775807?
> 
> And after? :)

Try it!

>>> print sys.maxint + 1
9223372036854775808

When you start one thread per second

>>> sys.maxint / (60*60 * 24 * 365.25)
292271023045.3132

after less than 300 billion years the only thing that will change is the 
type:

>>> type(sys.maxint)
<type 'int'>
>>> type(sys.maxint + 1)
<type 'long'>

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-12 00:02 +0200

csiph-web