Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throttle to one request at a time, with 1/5 of a second wait. #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thejeff77
Copy link
Collaborator

Adding throttling via async lib queue functionality. Adding sleep for task wait of 1/5 of a second after each translation. Queue of 1 is still to many requests. Need bulk requests in a future release.

Using a queue of more than 1 would give me rate-limit-exceeded. Without the sleep, it also goes too fast.

Now its still really really fast, it just doesn't break.

… task wait of 1/5 of a second after each translation. Queue of 1 is still to many requests. Need bulk requests in a future release.
q.push({'node': node}, function(err) {
// Precondition, node has been parsed, and xml file has been replaced with translations.
fs.writeFileSync(filePath, $.xml());
});
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code was minimally changed, but structure is different resulting in a confusing PR.

Main difference are lines 169-175 above. This is the new way to add a task, pass data to the predefined processor function. I.E. - pass the node in and add the task to the queue.

@thejeff77
Copy link
Collaborator Author

Do not merge, needs some work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant