- assert(isinstance(artist_ids, list))
- found = []
- lookup = []
- for artist_id in artist_ids:
- a = _artists.get(artist_id, None)
- if not a:
- lookup.append(artist_id)
- else:
- found.append(a)
- if lookup:
- q = GetQuery('artist_list', '+'.join(str(x) for x in lookup))
- a = q.execute()
- if not a:
- raise JamendoAPIException(str(q))
- _update_cache(_artists, a)
- lookup = a
- return found + lookup
+ with _APILOCK:
+ assert(isinstance(artist_ids, list))
+ found = []
+ lookup = []
+ for artist_id in artist_ids:
+ a = _artists.get(artist_id, None)
+ if not a:
+ lookup.append(artist_id)
+ else:
+ found.append(a)
+ if lookup:
+ q = GetQuery('artist_list', '+'.join(str(x) for x in lookup))
+ a = q.execute()
+ if not a:
+ raise JamendoAPIException(str(q))
+ _update_cache(_artists, a)
+ lookup = a
+ return found + lookup