Merge pull request #4695 from ryanpetrello/oauth-token-exclusive-lock

move the oauth2 last_used update to the bottom of the request

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-09-10 12:55:15 +00:00 committed by GitHub
commit eaf3a28d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ import re
# Django
from django.core.validators import RegexValidator
from django.db import models
from django.db import models, connection
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
@ -121,7 +121,7 @@ class OAuth2AccessToken(AbstractAccessToken):
valid = super(OAuth2AccessToken, self).is_valid(scopes)
if valid:
self.last_used = now()
self.save(update_fields=['last_used'])
connection.on_commit(lambda: self.save(update_fields=['last_used']))
return valid
def save(self, *args, **kwargs):