Message11490

Author Ivan
Recipients Ivan
Date 2017-07-21.17:01:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500656499.05.0.0579039833714.issue2609@psf.upfronthosting.co.za>
In-reply-to
Content
Further investigation shown that this issue is due to using compiled re objects in multi-threading environment. Using the script below one can reproduce errors saying that certain attributes not present in org.python.modules.sre.MatchObject. This errors are not reproducible for jython2.7.0!

---- Then the question is -- should re be thread-safe at all?


import thread
import re
import time
REGEX = re.compile('((?:foo|bar)+)(\d*)E?')

def parse(line):
  m = REGEX.search(line)
  if m.groups():
    print m.group(1)

thread.start_new_thread(parse, ('foobarfoofoofoofoofoofoofoofoofoofoo234',))
thread.start_new_thread(parse, ('foobarbarbarbarbarbarbarbarbarbarfoo4E',))
thread.start_new_thread(parse, ('foofoofoofoofoofoofoofoofoofoofoofoo434',))
thread.start_new_thread(parse, ('barbarbarbarbarbarbarbarbarfoofoo4',))
thread.start_new_thread(parse, ('foobarbarbarbarbarbarbarfoofoofoofoofoofoofoobarfoo4',))
thread.start_new_thread(parse, ('foobarbarbarbarbarbarbarbarbarfoo3424',))
thread.start_new_thread(parse, ('foofoobarfoobarfoobarfoobarfoobar333334E',))
thread.start_new_thread(parse, ('barfoofoo4barfoofoobarfoofoo4barfoofoo4barfoofoo4barfoofoo4',))
thread.start_new_thread(parse, ('foofoofoobarbarfoofoobarbarfoofoobarbarfoofoobarbar4',))
thread.start_new_thread(parse, ('foobarbarbarbarbarbarbarfoofoofoofoofoofoofoobarfoo4',))
thread.start_new_thread(parse, ('foobarbarbarbarbarbarbarbarbarfoo3424',))
thread.start_new_thread(parse, ('foofoobarfoobarfoobarfoobarfoobar333334E',))
thread.start_new_thread(parse, ('barfoofoo4barfoofoobarfoofoo4barfoofoo4barfoofoo4barfoofoo4',))
thread.start_new_thread(parse, ('foofoofoobarbarfoofoobarbarfoofoobarbarfoofoobarbar4',))

time.sleep(1)
History
Date User Action Args
2017-07-21 17:01:39Ivansetmessageid: <1500656499.05.0.0579039833714.issue2609@psf.upfronthosting.co.za>
2017-07-21 17:01:39Ivansetrecipients: + Ivan
2017-07-21 17:01:38Ivanlinkissue2609 messages
2017-07-21 17:01:38Ivancreate