[ZODB-Dev] Webkit Threading and ZODB 3.3a2: problems on Windows

Tim Peters tim at zope.com
Thu Feb 19 13:03:00 EST 2004


Running:

>> """
>> import thread, time
>>
>> def worker():
>>     print thread.get_ident()
>>
>> for i in range(10):
>>     thread.start_new_thread(worker, ())
>>     time.sleep(1)
>> """

Christian reported:

> FWIW:
>
>     1026
>     1026
>     2050
>     2050
>     3074
>     3074
>     4098
>     4098
>     5122
>     5122
>     6146
>     6146
>     7170
>     7170
>     8194
>     8194
>     9218
>     9218
>     10242
>     10242
>
> Linux manonegra 2.4.21k7 #8 Tue Jun 17 18:05:29 BRST 2003 i686 unknown
>
> -rwxr-xr-x    1 root     root      1153784 Apr  8  2003
> /lib/libc-2.2.5.so*

Really?!  The test program prints 10 lines of output.  Do you really get 20
lines?  Ah ... OK, you must have run this interactively, from a Python
shell.  Then the return value from

    thread.start_new_thread(worker, ())

gets displayed too, and that's the same as what thread.get_ident() returns
for the thread.  Had me going there <wink>.

Anyway, as expected, Linux doesn't reuse tids often, but Windows reuses them
as soon as it can.  Typical output for me on Windows (running from an
interactive shell too, to match the style above):

-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973
-762973

Alas, it wasn't clear in the original report whether threads *are* getting
created and destroyed, or whether the threads in the pool hang around
forever.  If the latter, it doesn't matter how ofter tids get reused;
whether on Linux or Windows, no two threads *simultaneously* alive will
return the same tid.




More information about the ZODB-Dev mailing list