Jump to content

Batch Calls


eight

Recommended Posts

Posted

Is it possible to make batch calls with the API? Making a lot of API calls tends to freeze the program, so I've had to go multithreaded. Using multiple threads doesn't seem like the right way to go for something that's just waiting on network calls. So I feel like it would be more appropriate to use some kind of batch network call if there's one available. I just couldn't find anything like it in the documentation.

Posted

It's hard to say exactly what I need to batch because it could be anything. But right now, I'm trying to get a bunch of info for several Tasks, as well as their Assets, Versions, and Components.

 

I guess I was looking for something like the get method, but being able to put in *args. I don't know how it would work if you wanted to get child object properties as part of the batch though.

Something like this made-up code:

task.get(getTaskCallback, 'name', 'parents', 'thumbnail', 'status', 'assets')def getTaskCallback(data):  taskUi.name = data['name']  taskUi.parents = data['parents']  taskUi.thumbnail = data['thumbnail']  taskUi.status = data['status']  for asset in data['assets']:    asset.get(getAssetCallback, 'name', 'versions')def getAssetCallback(data):  taskUi.addAsset(data)  # etc etc

I feel it would be better without having to chain so many callbacks, but I couldn't think of an elegant way to do it.

Anyway, I'm looking forward to the new API.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...