Skip to content

Commit

Permalink
fix lock cleanup for few cases
Browse files Browse the repository at this point in the history
Signed-off-by: Rafał Safin <[email protected]>
  • Loading branch information
Rafał Safin committed Sep 10, 2024
1 parent 2c54b63 commit 44e7ff6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
5 changes: 1 addition & 4 deletions base/views/outline_initial_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def initial_form( # noqa: PLR0912,PLR0911
# remove old locks
models.OutlineWriteLock.objects.filter(
outline_id=instance.pk,
lock_name=models.OutlineWriteLock.LOCK_NAME_TYPES.CREATE_WEIGHTMAX,
lock_expire__lt=now,
).delete()

Expand Down Expand Up @@ -206,7 +205,6 @@ def initial_form( # noqa: PLR0912,PLR0911
# remove old locks
models.OutlineWriteLock.objects.filter(
outline_id=instance.pk,
lock_name=models.OutlineWriteLock.LOCK_NAME_TYPES.CREATE_WEIGHTMAX,
lock_expire__lt=now,
).delete()

Expand Down Expand Up @@ -883,14 +881,13 @@ def complete_outline(request: HttpRequest, id1: int) -> HttpResponse:
now = timezone.now()
models.OutlineWriteLock.objects.filter(
outline_id=instance.pk,
lock_name=models.OutlineWriteLock.LOCK_NAME_TYPES.WRITE_OUTLINE,
lock_expire__lt=now,
).delete()
# try acquire lock on outline for 120s or result in error
lock, created = models.OutlineWriteLock.objects.get_or_create(
outline_id=instance.pk,
lock_name=models.OutlineWriteLock.LOCK_NAME_TYPES.WRITE_OUTLINE,
defaults={"lock_expire": now + timedelta(seconds=720)},
defaults={"lock_expire": now + timedelta(seconds=600)},
)
if not created:
return outline_being_written_error(instance, request, lock)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["rafsaf <[email protected]>"]
description = "Tribal Wars Planer django app, professional tool for creating outlines for off-game coordinators."
name = "tribal_wars_planer"
version = "5.2.0"
version = "5.2.1"

[tool.poetry.dependencies]
python = ">=3.12,<3.13"
Expand Down

0 comments on commit 44e7ff6

Please sign in to comment.