[Grinder-use] thread-save reading of testdata from csv file
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
|
From: Thomas F. <tho...@lp...> - 2010-09-30 11:11:34
|
Hi all,
this is not particulary grinder-specific, it's rather a jython-question but I guess some of you might have come across this before.
In my script I use a simple filereader to read values for the tests:
from threading import Condition
from threading import Lock
#at the top of the script:
f = codecs.open(csvFile, 'r',encoding='iso-8859-1')
def __call__(self):
...
lock = Lock()
lock.acquire()
csvValues = f.readline().rstrip("\r\n").split(',')
lock.release()
...
So from my understanding access to the file-object should be synchronized between the worker-threads. However, this does not work reliably. Sometimes the csvValues are just wrong or do not contain all bytes. Before I dig any deeper into this and write a testcase and test different mechanisms of the threading module, I would like to know if any of you know cause and the solution to this issue.
How have you implemented test-data reading? Maybe it would be better to use the csv module, but I guess that would not solve the problem.
Thanks
Thomas
|