pattern = re.compile('-rf')
... but this doesn't:
pattern = re.compile('-rf.?*')
This code is in the
runTestSuite()
method, which is called by TestRunner.__call__
. This is executed by every Grinder worker thread. It fails with the following error message:23/11/11 10:03:34 (thread 0 run 0): Aborted run due to Jython exception: <type 'exceptions.ValueError'>: ('unsupported operand type', 'any') [calling TestRunner]
The reason for this is that each thread must import the
re
module separately. One way to get around the error is to compile the regular expression in a helper method outside any Grinder worker thread, and invoke the helper method from worker threads:# compile regular expression def getRfRe(): import re return re.compile(r"-rf.*?\s") # use it from within runTestSuite() or any other worker thread match = getRfRe().search(req) if match: value = match.group(0)
Here is a link to the section in the Grinder FAQ that describes this in more detail: http://grinder.sourceforge.net/faq.html#re-problems