diff --git a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/storage.py b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/storage.py index 55f375fb4..62d0858a0 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/common/storage.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/common/storage.py @@ -5,6 +5,11 @@ from opencensus.common.schedule import PeriodicTask +try: + from pathlib import Path +except ImportError: + from pathlib2 import Path # python 2 backport + def _fmt(timestamp): return timestamp.strftime('%Y-%m-%dT%H%M%S.%f') @@ -109,7 +114,7 @@ def __exit__(self, type, value, traceback): def _maintenance_routine(self, silent=False): try: if not os.path.isdir(self.path): - os.makedirs(self.path) + os.makedirs(self.path, exist_ok=True) except Exception: if not silent: raise