Strange problem when using re module with threads

Wei Lee Woon wlwoon at gmail.com
Thu Nov 1 16:01:36 EDT 2007


Dear all

I've been getting a rather strange problem with the following multithreaded
code (reduced to the minimum which still results in the problem):

import threading
import re

class hey(threading.Thread):
    def run(self):
        print re.compile("\d+").search("hey95you").group();

thlist=[]
for tech in range(2):
    thlist.append(hey())
    thlist[-1].start()

for th in thlist:
    th.join()

After saving this to a file (say "test.py"), if I try to run this from the
console using "python test.py", it seems to work fine, but when i try to run
it from the python interactive shell using "import test", it freezes up (if
i don't issue the join() it is fine, though). Any ideas why this is so?

Thanks
Wei Lee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071101/6375b290/attachment.html>


More information about the Python-list mailing list