diff options
author | Dylan Baker <dylanx.c.baker@intel.com> | 2014-12-11 15:32:46 -0800 |
---|---|---|
committer | Dylan Baker <dylanx.c.baker@intel.com> | 2014-12-12 16:29:58 -0800 |
commit | b59ff71eb37b3ee01e5a34dda1a7ccbd4ba936f0 (patch) | |
tree | 499bf522297b5a7d83879e41303cca448402a3a0 /generated_tests/genclbuiltins.py | |
parent | c1cf7865e742666ba46197827af1a854215cbd17 (diff) |
generated_tests: Except error for os.makedirs
Currently we check for the existence of a directory, and if it doesn't
exist we create it. This would be fine, except that multiple generators
can create the same directory trees. When os.makedirs tries to create a
tree that already exists it raises and OSError exception, with the errno
set to 17 (the File Exists Error). Since between the time that a check
is made and the time the os.makedirs completes a second generator can
create the directory tree we can have exceptions raised sporadically,
especially as the number of threads being used to generate goes up.
We maintain the check for existence before trying to create the
directories because os.makedirs is slow, so not even trying is better
than trying in vain.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'generated_tests/genclbuiltins.py')
-rw-r--r-- | generated_tests/genclbuiltins.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/generated_tests/genclbuiltins.py b/generated_tests/genclbuiltins.py index 571930d8a..9dd371c7c 100644 --- a/generated_tests/genclbuiltins.py +++ b/generated_tests/genclbuiltins.py @@ -355,7 +355,12 @@ def print_test(f, fnName, argType, functionDef, tests, numTests, vecSize, tss): def gen(types, minVersions, functions, testDefs, dirName): # Create the output directory if required if not os.path.exists(dirName): - os.makedirs(dirName) + try: + os.makedirs(dirName) + except OSError as e: + if e.errno == 17: # file exists + pass + raise # Loop over all data types being tested. Create one output file per data # type |