-
Notifications
You must be signed in to change notification settings - Fork 141
Prevent Runtime use over forks
#1208
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
Merged
Merged
+323
−14
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…prevent_default to allow users to more easily enforce that a default runtime is never automatically created
…nstrate that you can call prevent_default and then set_default to allow future calls to default. add tests for set_default
cretz
reviewed
Nov 12, 2025
Member
cretz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, non-blocking concern about if we need the entire new RuntimeRef class to add a global boolean
…lag in favor of using the optional nature of _default_runtime in _RuntimeRef
cretz
approved these changes
Nov 14, 2025
tconley1428
approved these changes
Nov 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Raise an assertion error when a Runtime is used by client/worker creation/usage.
What was changed
RuntimeErrorif the runtime was created by a different process._RuntimeRefprivate class to encapsulate behavior around managing calls toRuntime.default_default_runtimewith an instance of the new_RuntimeRefand use it in calls toRuntime.default,Runtime.prevent_defaultandRuntime.set_default.Why?
Startup time in large codebases can be challenge to manage. One strategy to manage startup time is to load modules once and then fork the process into many instances so the child process don't need to repeat the startup cost. These changes help users employing that strategy to manage Temporal usage across forks in a safe manner.
Checklist
Closes [Feature Request] Better prevention of accidental
Runtimeuse over forks #1201How was this tested:
Client.connectafterRuntime.defaultwas called pre-forkRuntime.defaultwas called pre-fork_RuntimeRefclass that the lifecycle of default runtime.