Jump to >

djblets.db.managers

class ConcurrencyManager[source]

Bases: django.db.models.manager.Manager

A class designed to work around database concurrency issues.

get_or_create(**kwargs)[source]

A wrapper around get_or_create that makes a final attempt to get the object if the creation fails.

This helps with race conditions in the database where, between the original get() and the create(), another process created the object, causing us to fail. We’ll then execute a get().

This is still prone to race conditions, but they’re even more rare. A delete() would have to happen before the unexpected create() but before the get().