Plugin problems – asynchronous tasks

picard-plugins
Tags: #<Tag:0x00007fe3d0730b20>

#1

I am having trouble with my wikidata plugin and processing asynchronous requests.

This plugin uses the same hack used in the album artist plugin.
I increment and decremented album._requests and when no further requests are pending I call album._finalize_loading(None)
This trick works ok when you are processing either a release group level plugin or a track level plugin but not both.

If I call _finalize_loading after collecting the information for the release it then hangs as these tags are being processed while i try and update them.
If i do not call _finalize_loading then it processes the release group metadata but not the track metadata and does not finish loading as there are pending requests.

Is there a proper way of performing asynchronous tasks in a metadata plugin?

For most plugins this is not a problem as the function to process metadata does all its tasks and returns to the client.

I am after suggestions.

It may be possible to create a delay loop in my process album metadata plugin so this processing function does not return until all pending requests have been performed but I am not sure if that will cause threading problems.