Skip to content

Commit

Permalink
Allow modules using load_dotenv to be reloaded when launched in a sep…
Browse files Browse the repository at this point in the history
…arate thread (#497)

Update `is_interactive` code
  • Loading branch information
freddyaboulton authored Jan 23, 2024
1 parent 3ffcef6 commit 0b94ac0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dotenv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ def find_dotenv(

def _is_interactive():
""" Decide whether this is running in a REPL or IPython notebook """
main = __import__('__main__', None, None, fromlist=['__file__'])
try:
main = __import__('__main__', None, None, fromlist=['__file__'])
except ModuleNotFoundError:
return False
return not hasattr(main, '__file__')

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

0 comments on commit 0b94ac0

Please sign in to comment.