Skip to content

None of the switch_db or switch_collection support is thread-safe #2685

@jessemcl-flwls

Description

@jessemcl-flwls

As per this long standing issue: #788

It seems the original intent of these switching mechanisms was to support archiving or similar use-cases.

However, more generally, I may just have a document model that I want to use against many different Mongo databases (all of which contain data for the same model) but all within the same Python process, and all concurrently (eg. if my application is a multi-user service). Ultimately, the name of the database to use for any given call into the system could even be completely dynamic, i.e. driven by user inputs to the system itself.

To support this, we need to use thread locals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions