You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposal here is to fully adopt the code held in django_pglocks_advisory_lock. That means that we would extract several parts of the logic into the new method:
elifisinstance(lock_id, str):
# Generates an id within postgres integer range (-2^31 to 2^31 - 1).# crc32 generates an unsigned integer in Py3, we convert it into# a signed integer using 2's complement (this is a noop in Py2)pos=crc32(lock_id.encode("utf-8"))
lock_id= (2**31-1) &posifpos&2**31:
lock_id-=2**31
We would put this in a new method, takes a string, returns an integer. Also, very interesting for debugging, we could make a reverse method for debugging, so it takes an integer and returns the string that produced it? We could even have a method that returned a list of all the locks being held, maybe?
Next, we should change the import of from django.db connections to the more direct from django.db.transaction import get_connection
The text was updated successfully, but these errors were encountered:
Followup from #661
The proposal here is to fully adopt the code held in
django_pglocks_advisory_lock
. That means that we would extract several parts of the logic into the new method:We would put this in a new method, takes a string, returns an integer. Also, very interesting for debugging, we could make a reverse method for debugging, so it takes an integer and returns the string that produced it? We could even have a method that returned a list of all the locks being held, maybe?
Next, we should change the import of
from django.db connections
to the more directfrom django.db.transaction import get_connection
The text was updated successfully, but these errors were encountered: