Skip to content

Commit

Permalink
Rename constant
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed May 14, 2021
1 parent 17f020d commit 87d49f1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/layman/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def finish_publication_chain(last_task_id_in_chain):
rds.hdel(key, hash)

lock = redis_util.get_publication_lock(username, publication_type, publication_name)
if lock in [common.REQUEST_METHOD_PATCH, common.REQUEST_METHOD_POST, common.PUBLICATION_LOCK_WFST, ]:
if lock in [common.REQUEST_METHOD_PATCH, common.REQUEST_METHOD_POST, common.PUBLICATION_LOCK_FEATURE_CHANGE, ]:
redis_util.unlock_publication(username, publication_type, publication_name)


Expand Down
2 changes: 1 addition & 1 deletion src/layman/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
PUBLICATION_LOCK_POST = REQUEST_METHOD_POST
PUBLICATION_LOCK_PATCH = REQUEST_METHOD_PATCH
PUBLICATION_LOCK_DELETE = REQUEST_METHOD_DELETE
PUBLICATION_LOCK_WFST = 'wfst'
PUBLICATION_LOCK_FEATURE_CHANGE = 'feature_change'

InternalSourceTypeDef = namedtuple('InternalSourceTypeDef', ['info_items',
])
Expand Down
8 changes: 4 additions & 4 deletions src/layman/common/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def solve_locks(workspace, publication_type, publication_name, error_code, reque
if current_lock is None:
return
if requested_lock not in [common.PUBLICATION_LOCK_PATCH, common.PUBLICATION_LOCK_DELETE,
common.PUBLICATION_LOCK_WFST, ]:
common.PUBLICATION_LOCK_FEATURE_CHANGE, ]:
raise Exception(f"Unknown method to check: {requested_lock}")
if current_lock not in [common.PUBLICATION_LOCK_PATCH, common.PUBLICATION_LOCK_DELETE,
common.PUBLICATION_LOCK_POST,
common.PUBLICATION_LOCK_WFST, ]:
common.PUBLICATION_LOCK_FEATURE_CHANGE, ]:
raise Exception(f"Unknown current lock: {current_lock}")
if current_lock in [common.PUBLICATION_LOCK_PATCH, common.PUBLICATION_LOCK_POST, ]:
if requested_lock in [common.PUBLICATION_LOCK_PATCH, common.PUBLICATION_LOCK_POST, ]:
Expand All @@ -84,9 +84,9 @@ def solve_locks(workspace, publication_type, publication_name, error_code, reque
if requested_lock in [common.PUBLICATION_LOCK_PATCH, common.PUBLICATION_LOCK_POST, ]:
raise LaymanError(error_code)
if requested_lock not in [common.PUBLICATION_LOCK_DELETE, ]:
if requested_lock == common.PUBLICATION_LOCK_WFST:
if requested_lock == common.PUBLICATION_LOCK_FEATURE_CHANGE:
raise LaymanError(19, private_data={'can_run_later': True})
if current_lock == common.PUBLICATION_LOCK_WFST and requested_lock in [common.REQUEST_METHOD_PATCH, common.REQUEST_METHOD_POST, ]:
if current_lock == common.PUBLICATION_LOCK_FEATURE_CHANGE and requested_lock in [common.REQUEST_METHOD_PATCH, common.REQUEST_METHOD_POST, ]:
celery_util.abort_publication_chain(workspace, publication_type, publication_name)
celery_util.push_step_to_run_after_chain(workspace, publication_type, publication_name, 'layman.util::patch_after_feature_change')

Expand Down
2 changes: 1 addition & 1 deletion src/layman/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def delete_publications(user,

def patch_after_feature_change(workspace, publication_type, publication, **kwargs):
try:
redis.create_lock(workspace, publication_type, publication, 19, common.PUBLICATION_LOCK_WFST)
redis.create_lock(workspace, publication_type, publication, 19, common.PUBLICATION_LOCK_FEATURE_CHANGE)
except LaymanError as exc:
if exc.code == 19 and exc.private_data.get('can_run_later', False):
celery_util.push_step_to_run_after_chain(workspace, publication_type, publication,
Expand Down

0 comments on commit 87d49f1

Please sign in to comment.