Setting to turn off atomic transactions
See original GitHub issueThe methods run_task()
and run_next_task()
are both annotated @atomic
. I wonder what the reason for this is.
Django has a setting ATOMIC_REQUESTS
for tying transactions to HTTP requests. Could we have a similar setting to control whether background tasks are executed within an atomic transaction or not?
This could be useful for cases where people are forced to use SQLite, but want to minimize the time the database gets locked. Currently, the atomic transaction locks the database for the entire task duration even if only read-only transactions are executed. This can be problematic for long-running tasks that do network requests for example.
It would also give a task author the opportunity to control which parts of their tasks should be run within a transaction. Currently, you are forced into one large transaction.
PS. Yes, I am aware that SQLite does not support concurrency and that this is a known issue.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
How about we just drop the atomic decorator completely until an option is created? This is more confusing than helpful, especially since the documentation doesn’t mention either behavior at all.
@philippeowagner i don’t see any side effects when removing the decorator.
I just removed the
@atomic
decorators and ran the tox test suite. Every test has passed. So removing it completely is fine for me.