Skip to content

Commit 0b94ac0

Browse files
Allow modules using load_dotenv to be reloaded when launched in a separate thread (#497)
Update `is_interactive` code
1 parent 3ffcef6 commit 0b94ac0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/dotenv/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ def find_dotenv(
280280

281281
def _is_interactive():
282282
""" Decide whether this is running in a REPL or IPython notebook """
283-
main = __import__('__main__', None, None, fromlist=['__file__'])
283+
try:
284+
main = __import__('__main__', None, None, fromlist=['__file__'])
285+
except ModuleNotFoundError:
286+
return False
284287
return not hasattr(main, '__file__')
285288

286289
if usecwd or _is_interactive() or getattr(sys, 'frozen', False):

0 commit comments

Comments
 (0)