Comments (2)
If two threads run this code concurrently, thread 2 will block on the get_next_value
call and won't start executing # Code B
until thread 1 finishes executing # Code C
.
This is fairly easy to test by replacing # Code X
with print("enter X"); time.sleep(10); print("exit X")
and running the script in two terminals side by side.
If you try it, I'm interested in a confirmation that the behavior is indeed what I predicted.
PS - if you enabled the ATOMIC_REQUESTS
option (which you probably did if you care enough about transactions to look at django-sequences) then the outer atomic
block is created by Django and wraps the entire view.
from django-sequences.
Thanks for the reply. I can confirm your elaboration. I tested it "manually" using debugger and indeed, thread 2 would block until Code C is fully executed. It works like nesting atomic blocks.
And as to your PS - I did not enable ATOMIC_REQUESTS
, and did it deliberately. I do not want requests to be atomic. This is actually the only case I need locking and syncing between requests. I do not want to loose performance :]
Thanks again for the clarification!
from django-sequences.
Related Issues (20)
- Python 2.x support HOT 1
- Feature request: Get current value HOT 5
- django-sequences version 2.4 is not supporting HOT 10
- Syntax Error sequences/__init__.py, line 29 on Python 3.5.9 HOT 2
- Help elaborate the background of the problem? HOT 5
- reset value does not work with PostgresDB HOT 1
- Document usage with different isolation levels HOT 3
- Deprecation warning: django.utils.translation.ugettext_lazy() is deprecated HOT 2
- New release HOT 1
- Detecting duplicate sequence name HOT 4
- Extend contributing instructions
- Calling get_next_value() in multiple paralel requests can cause huge database lags HOT 4
- Rename master branch to main HOT 1
- About daily sequence HOT 7
- PositiveBigIntegerField HOT 6
- Initial Django Migration Issue HOT 1
- Separate sequence property specifiers HOT 2
- dropping old sequences HOT 4
- Expand get_next_value for multiple sequences HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-sequences.