• 
      

    Differentiate between servers, workers, and scripts during initialization.

    Review Request #15246 — Created Aug. 20, 2026 and updated

    Information

    Review Board
    release-9.x

    Reviewers

    Review Board's gaining worker support, and already differs when run
    backed by a web server or via a script, but until now we've had no way
    of telling what mode Review Board is in.

    This change adds a process_mode= argument to initialize() for
    specifying a mode. This default to default, which is used for scripts
    or other operations, but can be put into server or worker mode.

    Right now, there's no difference between the modes, but going forward
    we'll be able to alter setup or key off some functionality based on the
    mode. For example, servers will be able to launch workers, but scripts
    and workers will not.

    The current mode is available via
    reviewboard.process.get_rb_process_mode() and via the
    $RB_PROCESS_MODE environment variable.

    There's a bit of cleanup in the initialization while here to avoid
    redundant or unnecessary calls. Some of this may be updated based on the
    process mode in a later change.

    All unit tests pass.

    Ran locally and saw that Review Board was initialized in server mode.

    Summary ID
    Differentiate between servers, workers, and scripts during initialization.
    Review Board's gaining worker support, and already differs when run backed by a web server or via a script, but until now we've had no way of telling what mode Review Board is in. This change adds a `process_mode=` argument to `initialize()` for specifying a mode. This default to `default`, which is used for scripts or other operations, but can be put into `server` or `worker` mode. Right now, there's no difference between the modes, but going forward we'll be able to alter setup or key off some functionality based on the mode. For example, servers will be able to launch workers, but scripts and workers will not. The current mode is available via `reviewboard.process.get_rb_process_mode()` and via the `$RB_PROCESS_MODE` environment variable. There's a bit of cleanup in the initialization while here to avoid redundant or unnecessary calls. Some of this may be updated based on the process mode in a later change.
    1216ca878ca24a2c0ff1a9bb055f4c187166c669
    Description From Last Updated

    manage.py is calling initialize() without a mode, including for runserver. We end up re-initializing on the first request which ends …

    david david

    Should the initialize() in rbsite.py set a mode other than DEFAULT?

    david david

    StrEnum is Python 3.11+. Existing pattern is to inherit from (str, Enum) with a TODO comment.

    david david

    Should be :py:func:

    david david

    This has nothing in the manual to link to.

    david david

    This seems write-only. Is this here to persist the mode to child processes? If so, initialize() should probably be reading …

    david david

    This will crash if called before initialize(). Can we declare the module-level global with a doc comment and type annotation?

    david david
    Checks run (2 succeeded)
    flake8 passed.
    JSHint passed.
    david
    1. 
        
    2. Show all issues

      manage.py is calling initialize() without a mode, including for runserver. We end up re-initializing on the first request which ends up setting the mode to SERVER, but it would be nice to be explicit.

    3. Show all issues

      Should the initialize() in rbsite.py set a mode other than DEFAULT?

    4. reviewboard/process.py (Diff revision 1)
       
       
      Show all issues

      StrEnum is Python 3.11+. Existing pattern is to inherit from (str, Enum) with a TODO comment.

    5. reviewboard/process.py (Diff revision 1)
       
       
      Show all issues

      Should be :py:func:

    6. reviewboard/process.py (Diff revision 1)
       
       
      Show all issues

      This has nothing in the manual to link to.

    7. reviewboard/process.py (Diff revision 1)
       
       
      Show all issues

      This seems write-only. Is this here to persist the mode to child processes?

      If so, initialize() should probably be reading this, and setting RBProcessMode.DEFAULT only if the envvar is empty.

    8. reviewboard/process.py (Diff revision 1)
       
       
      Show all issues

      This will crash if called before initialize().

      Can we declare the module-level global with a doc comment and type annotation?

    9.