Thread-ID - how much could be?
Chris Angelico
rosuav at gmail.com
Thu Sep 11 21:49:07 EDT 2014
On Fri, Sep 12, 2014 at 11:29 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> I know that some Linux
> systems can have an uptime over a year, perhaps even two years, but I think
> that nearly 300 years is asking a bit much. Your hardware probably won't
> keep working that long.
I've had over two years of uptime. Currently looking at 85 wk 4d
02:11:28 since the UPS and power failed simultaneously, but before
that, over two years.
But what about a 32-bit build? You could blow 1<<31 in about a month
of milliseconds, and I just tried, and on this 32-bit Windows box I
have here, I can start 10K threads in under a second:
>>> def test(n):
def f(): pass
start=time.time()
for i in range(n):
t=threading.Thread(target=f)
return (time.time()-start)/n
>>> test(10000)
6.562459468841553e-05
>>> test(100000)
6.906198978424073e-05
So if it's 7e-5 seconds per thread (65-69 microseconds), that'd be
less than two days to blow a 32-bit maxint. You could probably keep
even a Win 98 computer running that long!
ChrisA
More information about the Python-list
mailing list