Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/functions_framework/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,7 @@ def create_app(target=None, source=None, signature_type=None):
global errorhandler
errorhandler = app.errorhandler

# 6. Execute the module, within the application context
with app.app_context():
spec.loader.exec_module(source_module)

# Handle legacy GCF Python 3.7 behavior
# 6. Handle legacy GCF Python 3.7 behavior
if os.environ.get("ENTRY_POINT"):
os.environ["FUNCTION_TRIGGER_TYPE"] = signature_type
os.environ["FUNCTION_NAME"] = os.environ.get("K_SERVICE", target)
Expand All @@ -254,6 +250,10 @@ def handle_none(rv):
sys.stderr = _LoggingHandler("ERROR", sys.stderr)
setup_logging()

# 7. Execute the module, within the application context
with app.app_context():
spec.loader.exec_module(source_module)

# Extract the target function from the source file
if not hasattr(source_module, target):
raise MissingTargetException(
Expand Down