Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move backwards-compatible logic before function source load #152

Merged
merged 4 commits into from
Oct 12, 2021
Merged
Changes from 2 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