pythonmultithreadingazure-devopspython-multithreading

Multithreading in Azure Api


I need to write almost 300 different wiki page all separated by type : [Epic, Features, ....] using Azure devops python Api

And this take me many minutes when i write them one by one

So i tried to do a basic multithreading

if (multithreading):
        threads = []
        for task in task_list:
            thread = threading.Thread(target=write_one_epic, args=(task, requests_session)
            thread.start()
            threads.append(thread)
        for thread in threads:
            thread.join()

This result me in this error

The wiki page operation failed with message : TF401028: The reference 'refs/heads/wikiMaster' has already been updated by another client, so you cannot update it. Please try again.

Update, i tried with a ThreadPoolExecutor and it result me as the same error

The error is raised when i try to create a new page

wiki.create_or_update_page(content, Constant.project, Constant.wikiIdentifier, self.actual_path, None)

Solution

  • The wiki page operation failed with message : TF401028: The reference 'refs/heads/wikiMaster' has already been updated by another client, so you cannot update it. Please try again.

    It could happen when running parallel updates to the same wiki.

    You can only push to the remote if you are up to date, try to pull the data before update, and put in a retry loop and small interval between each try. please check the similar link here for the details.

    In addition, the Azure DevOps python api is a thin wrapper around the Azure DevOps REST APIs. You can try to use the REST API directly for this operation. You can find the sample script in link here.