Skip to content

Move exception handling up the stack (avoid exit(1) in our composable functions)#19116

Merged
MadLittleMods merged 5 commits intodevelopfrom
madlittlemods/handle-startup-exception-in-main
Nov 3, 2025
Merged

Move exception handling up the stack (avoid exit(1) in our composable functions)#19116
MadLittleMods merged 5 commits intodevelopfrom
madlittlemods/handle-startup-exception-in-main

Conversation

@MadLittleMods
Copy link
Copy Markdown
Contributor

@MadLittleMods MadLittleMods commented Oct 30, 2025

Move exception handling up the stack (avoid exit(1) in our composable functions)

Relevant to Synapse Pro for small hosts as we don't want to exit the entire Python process and affect all homeserver tenants.

Background

As part of Element's plan to support a light form of vhosting (virtual host) (multiple instances of Synapse in the same Python process) (c.f Synapse Pro for small hosts), we're currently diving into the details and implications of running multiple instances of Synapse in the same Python process.

"Clean tenant provisioning" tracked internally by https://github.com/element-hq/synapse-small-hosts/issues/48

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

@MadLittleMods MadLittleMods changed the title Move exception handling up the stack (avoid exit(1)) Move exception handling up the stack (avoid exit(1) in our composable functions) Oct 30, 2025
@MadLittleMods MadLittleMods marked this pull request as ready for review October 30, 2025 23:24
@MadLittleMods MadLittleMods requested a review from a team as a code owner October 30, 2025 23:24
Copy link
Copy Markdown
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Nice small cleanup.

@MadLittleMods MadLittleMods merged commit e00a411 into develop Nov 3, 2025
73 of 76 checks passed
@MadLittleMods MadLittleMods deleted the madlittlemods/handle-startup-exception-in-main branch November 3, 2025 17:19
@MadLittleMods
Copy link
Copy Markdown
Contributor Author

Thanks for the review @anoadragon453 🐏

(in time for RC tomorrow 🙏)

MadLittleMods added a commit that referenced this pull request Nov 3, 2025
#19121)

- Move `register_start` (calls `os._exit(1)`) out of `setup` (our
composable function)
- We want to avoid `exit(...)` because we use these composable functions
in Synapse Pro for small hosts where we have multiple Synapse instances
running in the same process. We don't want a problem from one homeserver
tenant causing the entire Python process to exit and affect all of the
other homeserver tenants.
     - Continuation of #19116
- Align our app entrypoints: `homeserver` (main), `generic_worker`
(worker), and `admin_cmd`

### Background

As part of Element's plan to support a light form of vhosting (virtual
host) (multiple instances of Synapse in the same Python process) (c.f
Synapse Pro for small hosts), we're currently diving into the details
and implications of running multiple instances of Synapse in the same
Python process.

"Clean tenant provisioning" tracked internally by
element-hq/synapse-small-hosts#48
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