Skip to content

Commit

Permalink
Adjust dispatch calls to core>=3.15 interface
Browse files Browse the repository at this point in the history
fixes # 9483
  • Loading branch information
mdellweg committed Oct 4, 2021
1 parent 8c6b54f commit 2a55279
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES/9483.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed the use of ``dispatch`` to match the signature from pulpcore>=3.15.
2 changes: 1 addition & 1 deletion pulp_ansible/app/galaxy/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ def _dispatch_import_collection_task(self, temp_file_pk, repository=None, **kwar
locks.append(repository)
kwargs["repository_pk"] = repository.pk

return dispatch(import_collection, locks, kwargs=kwargs)
return dispatch(import_collection, exclusive_resources=locks, kwargs=kwargs)
2 changes: 1 addition & 1 deletion pulp_ansible/app/galaxy/v3/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def update(self, request, *args, **kwargs):

task = dispatch(
add_and_remove,
[repo_version.repository],
exclusive_resources=[repo_version.repository],
kwargs={
"repository_pk": repo_version.repository.pk,
"base_version_pk": repo_version.pk,
Expand Down
4 changes: 2 additions & 2 deletions pulp_ansible/app/tasks/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ def promote_content(repos_per_task, num_repos_to_update):
locks.append(repo)
if len(repos_to_dispatch) == repos_per_task:
task_args = (random_collection_version.pk, repos_to_dispatch)
dispatch(add_content_to_repositories, locks, args=task_args)
dispatch(add_content_to_repositories, exclusive_resources=locks, args=task_args)
repos_to_dispatch = []
locks = []

if repos_to_dispatch:
task_args = (random_collection_version.pk, repos_to_dispatch)
dispatch(add_content_to_repositories, locks, args=task_args)
dispatch(add_content_to_repositories, exclusive_resources=locks, args=task_args)


def add_content_to_repositories(collection_version_pk, repositories_pks):
Expand Down
6 changes: 3 additions & 3 deletions pulp_ansible/app/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def sync(self, request, pk):

result = dispatch(
sync_func,
[repository, remote],
exclusive_resources=[repository, remote],
kwargs=sync_kwargs,
)
return OperationPostponedResponse(result, request)
Expand Down Expand Up @@ -304,7 +304,7 @@ def update(self, request, pk, **kwargs):
lock.extend(repos)
async_result = dispatch(
update_collection_remote,
lock,
exclusive_resources=lock,
args=(pk,),
kwargs={"data": request.data, "partial": partial},
)
Expand Down Expand Up @@ -401,7 +401,7 @@ def create(self, request):

config, repos = self._process_config(config)

async_result = dispatch(copy_content, repos, args=[config], kwargs={})
async_result = dispatch(copy_content, exclusive_resources=repos, args=[config], kwargs={})
return OperationPostponedResponse(async_result, request)

def _process_config(self, config):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
while repos_to_still_make > 0:
if repos_to_still_make >= args.batch_size[0]:
task_args = (args.batch_size[0], num_repo_versions_per_repo, collection_percentage)
async_result = dispatch(create_repos_with_collections, [], args=task_args)
async_result = dispatch(create_repos_with_collections, args=task_args)
print("Dispatched task with {} repositories".format(args.batch_size[0]))
repos_to_still_make = repos_to_still_make - args.batch_size[0]
else:
task_args = (repos_to_still_make, num_repo_versions_per_repo, collection_percentage)
async_result = dispatch(create_repos_with_collections, [], args=task_args)
async_result = dispatch(create_repos_with_collections, args=task_args)
print("Dispatched task with {} repositories".format(repos_to_still_make))
repos_to_still_make = 0
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/fast_load_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
for file in files:
if file.endswith(".tar.gz"):
async_result = dispatch(
import_collection_from_path, [], args=(os.path.join(root, file),)
import_collection_from_path, args=(os.path.join(root, file),)
)
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/generate_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
"collection_n": args.collections_per_namespace[0],
"versions_per_collection": args.versions_per_collection[0],
}
async_result = dispatch(create_namespace, [], args=(args.base_path[0],), kwargs=kwargs)
async_result = dispatch(create_namespace, args=(args.base_path[0],), kwargs=kwargs)
2 changes: 1 addition & 1 deletion pulp_ansible/tests/performance/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

if __name__ == "__main__":
task_args = (args.repos_per_task[0], args.num_repos_to_update[0])
dispatch(promote_content, [], args=task_args)
dispatch(promote_content, args=task_args)

0 comments on commit 2a55279

Please sign in to comment.