Skip to content

Commit 4787132

Browse files
authored
Add an option (as an environment var) to disable cached namespace imports (#264)
1 parent 0265217 commit 4787132

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/basilisp/importer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from basilisp.lang.util import demunge
1616
from basilisp.util import timed
1717

18+
_NO_CACHE_ENVVAR = 'BASILISP_DO_NOT_CACHE_NAMESPACES'
19+
1820
MAGIC_NUMBER = (1149).to_bytes(2, 'little') + b'\r\n'
1921

2022
logger = logging.getLogger(__name__)
@@ -227,11 +229,14 @@ def exec_module(self, module):
227229

228230
# Check if a valid, cached version of this Basilisp namespace exists and, if so,
229231
# load it and bypass the expensive compilation process below.
230-
try:
231-
self._exec_cached_module(fullname, spec.loader_state, path_stats, module)
232-
except (EOFError, ImportError, IOError, OSError) as e:
233-
logger.debug(f"Failed to load cached Basilisp module: {e}")
232+
if os.getenv(_NO_CACHE_ENVVAR, None) == 'True':
234233
self._exec_module(fullname, spec.loader_state, path_stats, module)
234+
else:
235+
try:
236+
self._exec_cached_module(fullname, spec.loader_state, path_stats, module)
237+
except (EOFError, ImportError, IOError, OSError) as e:
238+
logger.debug(f"Failed to load cached Basilisp module: {e}")
239+
self._exec_module(fullname, spec.loader_state, path_stats, module)
235240

236241
# Because we want to (by default) add 'basilisp.core into every namespace by default,
237242
# we want to make sure we don't try to add 'basilisp.core into itself, causing a

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ python =
77

88
[testenv]
99
passenv = TRAVIS TRAVIS_*
10+
setenv =
11+
BASILISP_DO_NOT_CACHE_NAMESPACES = True
1012
deps =
1113
six==1.10.0
1214
commands =

0 commit comments

Comments
 (0)