Skip to content

Conversation

terrazoon
Copy link
Contributor

@terrazoon terrazoon commented Oct 2, 2025

Description

Because of the use of gevent and its need for monkey patching, it's necessary that all global variables that use resources be lazily initialized. This way the monkey patching works for the whole app, and we don't get fork errors under heavy load.

In the PR we do lazy initialization of all the 'easy' global variables, which don't hit too many files.

Note: This PR is a bit risky. Even though I ran a bulk send test locally and it was successful, the PR might destabilize staging. So we should push it to staging on its own and QA test it on its own, and be ready to rollback.

Security Considerations

N/A

@terrazoon terrazoon marked this pull request as draft October 2, 2025 14:37
@terrazoon terrazoon changed the title lazy initialize zendesk_client lazy initialize for gevent Oct 3, 2025
@terrazoon terrazoon marked this pull request as ready for review October 3, 2025 16:27
Copy link
Contributor

@ccostino ccostino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @terrazoon!

I agree about testing this in isolation when we merge it - I had one question on the new methods introduced, but I could very well not be seeing something!

Copy link
Contributor

@ccostino ccostino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again, @terrazoon!

@ccostino ccostino merged commit 7d20e25 into main Oct 3, 2025
7 checks passed
@ccostino ccostino deleted the lazyinit branch October 3, 2025 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants