GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(aws-lambda): Load path-style handlers once instead of on every invocation by pabloDeputter · Pull Request #8134 · getsentry/sentry-python

Conversation

@pabloDeputter

@pabloDeputter pabloDeputter commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Description

Path-style handlers, e.g. SENTRY_INITIAL_HANDLER=app/index.handler, were manually loaded and never cached unlike dotted handlers, e.g. index.handler which automatically ended up in sys.modules; so module was loaded again on every warm invocation and state was lost.

Changes & Results

Loader now does the same as Lambda runtime itself: / is turned into . and importlib.import(...) is called; Python caches the module, so it runs exactly once per execution environment.

Some results below on a Lambda function (python3.13, arm64, 512 MB) that creates 3 boto3 clients at import:

warm-duration

Warm invocations: p50 122ms => 58ms; p99 180ms => 69ms.

cold-start

Cold starts remain the same, 1.4s for both.

memory

Peak memory also drops from 117 MB => 108 MB and is fixed on invocations, unlike the old layer which grows over time because each call creates new clients.

Issues

Resolves #8079 & PY-3016

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pabloDeputter added 3 commits October 27, 2026 14:25
@pabloDeputter
.
b9e1d77
@pabloDeputter
wip - make more descriptive
989a0b9
@pabloDeputter
fix test
fac06dc
@pabloDeputter
pabloDeputter force-pushed the pablo/aws-lambda-load-handler-once branch from ca3a347 to fac06dc Compare October 27, 2026 13:27
@pabloDeputter
pabloDeputter marked this pull request as ready for review October 27, 2026 13:31
@pabloDeputter
pabloDeputter requested a review from a team as a code owner October 27, 2026 13:31
@github-actions

github-actions Bot commented Oct 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 138998 passed | ⏭️ 7669 skipped | Total: 146667 | Pass Rate: 94.77% | Execution Time: 458m 55s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +1552
Passed Tests 📈 +1554
Failed Tests —
Skipped Tests 📉 -2

All tests are passing successfully.

✅ Patch coverage is 100.00% (no changed executable lines found; target 80%).
Project statement coverage is 90.24% (down 0.01 percentage points from base (63707d7) to head (fb3fbfd)).

Coverage diff
@@            Coverage Diff             @@
##        master     #8134       +/-##
==========================================
- Coverage    90.25%    90.24%    -0.01%
==========================================
  Files          203       203         —
  Tracked lines     27114     27114         —
  Branches     10136     10136         —
==========================================
- Hits         24470     24468        -2
- Misses        2644      2646        +2
- Partials      1538      1540        +2

Generated by Coverage Action

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pabloDeputter and others added 2 commits October 28, 2026 15:10
@pabloDeputter
Merge branch 'master' into pablo/aws-lambda-load-handler-once
3194674
@sentry-junior @sentrivana
fix(aws-lambda): Keep accepting ./ and absolute task root handler paths
fb3fbfd
Co-Authored-By: Ivana Kellyer <[email protected]>
@sentry-junior sentry-junior Bot changed the title fix(aws-lambda): Load path-style handlers once per invocation fix(aws-lambda): Load path-style handlers once instead of on every invocation Nov 11, 2026
sentrivana
sentrivana approved these changes Nov 11, 2026
View reviewed changes
@sentrivana
sentrivana enabled auto-merge (squash) November 11, 2026 09:55
@sentrivana
sentrivana merged commit f6d6ce9 into master Nov 11, 2026
170 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sentrivana
sentrivana deleted the pablo/aws-lambda-load-handler-once branch November 11, 2026 10:01
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Nov 12, 2026
publish: getsentry/[email protected] getsentry/publish#10388
Closed
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sentrivana sentrivana sentrivana approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

fix(aws-lambda): Load handler module only once in the layer

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@pabloDeputter @sentrivana
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.