bugfix in queue handlers....

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-01-12 05:15:25 +03:00
parent 8820613fda
commit d6ade16950
4 changed files with 22 additions and 25 deletions

View File

@ -2708,23 +2708,21 @@ function(title, func){
// be run sync...
// NOTE: when chaining arg_handler(..) will get one queue per level of
// chaining, but in 'sync' mode only one 'sync' is passed...
// NOTE: when calling this multiple times for the same queue each call
// will call all the stages but since items are processes async the
// later calls' later stages may end up with empty input queues,
// e.g. for:
// [1,2,3].map(e => ig.exampleChainedQueueHandler(e))
// .exampleChainedQueueHandler(..) is called once per input and thus
// the first two stages are called sync and by the time the last
// stage of the first call is triggered (async) all the inputs are
// ready thus the first call will process all the inputs and the
// later calls will get empty inputs (unless any new inputs are while
// processing added)...
//
// XXX might be a good idea to split this into a generic and domain parts
// and move the generic part into types/runner...
// XXX check if item is already in queue...
// XXX BUG when this is called multiple times each thread is called from
// top to bottom even when consolidating the results into a single
// pack, e.g. for:
// [1,2,3].map(e => ig.exampleChainedQueueHandler(e))
// the .exampleChainedQueueHandler(..) is called once per input and:
// - pre-prep is called once per input
// - prep is called once per input
// - action is called once per input
// ...and since the inputs are already consolidated into a
// single container this will be called on that container
// once per input -> each input is processed N times...
// ...would either need to "consume" the inputs removing them from
// the input list or keep track of what we are calling...
var queueHandler =
module.queueHandler =
function(title, func){
@ -2798,7 +2796,13 @@ function(title, func){
args.length > 0
&& (args = [args])
q.add(items instanceof Array ?
items.map(function(e){
items
// move the inputs out of the input array...
// NOTE: this will prevent the items from getting
// processed multiple times when the action
// is called multiple times...
.splice(0, items.length)
.map(function(e){
return [e, ...args] })
: [[items, ...args]])
return q.promise() } }

View File

@ -190,13 +190,6 @@ var SharpActions = actions.Actions({
// XXX revise return values...
// XXX make backup name pattern configurable...
// XXX CROP ready for crop support...
// XXX BUG? seams to create backups uncontrollably...
// to reproduce:
// ig.data.order.map(gid => ig.makeResizedImage(gid, 100, 'moo'))
// this will add each image at least twice...
// ...this might actually be an issue in .queueHandler(..), feels
// like we might be editing the array we are iterating over,
// needs more investigation...
makeResizedImage: ['- Image/',
core.doc`Make resized image(s)...

View File

@ -1211,9 +1211,9 @@
"integrity": "sha512-qxAWSFdwE0PeBh5Ws+pyX3SxJrwqratEIDrSg5odcHdUVFTzATMJImH2L8bMaDhxaQJj5ogoZc+lx56UIpXJ1g=="
},
"ig-types": {
"version": "6.0.8",
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-6.0.8.tgz",
"integrity": "sha512-2Fd69Z/lOOTsU+algm+7BL//yDHbUYyorots9OvrF8fmDhk78T4QMZjPd7208xMG6NnuQRhmc3LbSA0yetf9pw==",
"version": "6.0.9",
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-6.0.9.tgz",
"integrity": "sha512-LexsEw0tSr2dVCU9iePRdxAnXVYwQ0yrFQ2xluFwh154E2NIX6EOmPdSVJJ1c+EruWUR2ZrShy7/3p33as/trg==",
"requires": {
"ig-object": "^5.4.16",
"object-run": "^1.0.1"

View File

@ -34,7 +34,7 @@
"ig-argv": "^2.16.3",
"ig-features": "^3.4.7",
"ig-object": "^5.4.16",
"ig-types": "^6.0.8",
"ig-types": "^6.0.9",
"json5": "^2.1.3",
"object-run": "^1.0.1",
"requirejs": "^2.3.6",