-
Notifications
You must be signed in to change notification settings - Fork 485
Description
Per JavaScript/ocrsdk.js
:
ocrsdk.com/JavaScript/ocrsdk.js
Lines 125 to 127 in 3087b80
// Note: if your application queues several files and waits for them | |
// it's recommended that you use listFinishedTasks instead (which is described | |
// at https://ocrsdk.com/documentation/apireference/listFinishedTasks/). |
It looks like the only sample that actually implements this recommendation is Java/Abbyy.Ocrsdk.client/srcProcessManyFiles.java
:
ocrsdk.com/Java/Abbyy.Ocrsdk.client/src/ProcessManyFiles.java
Lines 245 to 250 in 3087b80
private static void waitAndDownloadResults( Map<String,String> taskIds ) throws Exception { | |
// Call listFinishedTasks while there are any not completed tasks from taskIds | |
// Please note: API call 'listFinishedTasks' returns maximum 100 tasks | |
// So, to get all our tasks we need to delete tasks on server. Avoid running | |
// parallel programs that are performing recognition with the same Application ID |
Given the limit of 100 results, sorted by date ascending (?!), and with no way of paginating, it's necessary to manually delete each completed task once it's been downloaded. This seems very flaky — if the program crashes before completion, leaving several tasks un-downloaded, those tasks will presumably just hang around taking up space on the list of returned tasks forever. Once the number of such zombie tasks reaches 100, calls to /listFinishedTasks
will never return any relevant tasks, so the program will continue polling the endpoint forever until manually terminated.
Also, is there any real drawback to just polling /getTaskStatus
for each ongoing task? It's not clear what the benefit of polling /listFinishedTasks
is, given the increased complexity and flakiness. Presumably calls to /getTaskStatus
are cheap, as they don't send or return much data or do any processing, just check a status.