Skip to content

Commit

Permalink
mkdir_p check for residual from previous doctests, but may cause race…
Browse files Browse the repository at this point in the history
… condition
  • Loading branch information
hobs committed Dec 1, 2019
1 parent b180bfb commit c3af6bc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/nlpia/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
('User-Agent', 'Mozilla Firefox'),
('From', 'nlpia+github@totalgood.com'),
('Referer', 'http://github.com/totalgood/nlpia'),
)
)

LOG_LEVEL = 'WARN' if not os.environ.get('DEBUG') else 'DEBUG'
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand Down Expand Up @@ -104,7 +104,7 @@
except: # noqa
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
logger.warning('Starting logger in nlpia.constants...')
logger.info('Starting logger in nlpia.constants...')

USER_HOME = os.path.expanduser("~")
PROJECT_PATH = PRJECT_DIR = BASE_DIR
Expand Down Expand Up @@ -143,7 +143,10 @@ def mkdir_p(path, exist_ok=True):
Thank you Abhijit Mustafi for catching this bug and sharing it on Manning's Livebook comments.
>>> deeper_path = os.path.join(BIGDATA_PATH, 'doctest_nlpia', 'constants', 'mkdir_p')
>>> mkdir_p(deeper_path, exist_ok=False)
>>> if os.path.isdir(deeper_path):
... os.removedirs(deeper_path)
>>> if not os.path.isdir(deeper_path):
... mkdir_p(deeper_path, exist_ok=False)
>>> os.path.isdir(deeper_path)
True
>>> mkdir_p(deeper_path, exist_ok=True)
Expand Down

0 comments on commit c3af6bc

Please sign in to comment.