File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,21 @@ Worker.prototype.removePooler = function (pooler) {
209
209
}
210
210
} ;
211
211
212
+ Worker . prototype . removeTask = function ( pooler ) {
213
+ this . logger . debug ( 'removePooler' ) ;
214
+
215
+ const index = this . _poolers . indexOf ( pooler ) ;
216
+ if ( index === - 1 ) {
217
+ throw ( new Error ( `pooler ${ pooler } is not in the pooler list` ) ) ;
218
+ }
219
+
220
+ this . _poolers . splice ( index , 1 ) ;
221
+
222
+ if ( this . _poolers . length === 0 ) {
223
+ this . emit ( 'empty-poolers' ) ;
224
+ }
225
+ } ;
226
+
212
227
// Worker.prototype.removePooler = function () {
213
228
// if(!this._poolerRemovalPromise){
214
229
// this._poolerRemovalPromise = Promise.resolve()
@@ -290,10 +305,16 @@ Worker.prototype.stop = function () {
290
305
291
306
Worker . prototype . restart = function ( cb ) {
292
307
const oldPoolConcurrency = this . poolConcurrency ;
293
- return this . stop ( ) . then ( ( ) => {
308
+
309
+ const promise = this . stop ( ) . then ( ( ) => {
294
310
this . poolConcurrency = oldPoolConcurrency ;
295
- return this . start ( cb ) ;
311
+ return this . start ( ) ;
296
312
} ) ;
313
+ if ( cb ) {
314
+ promise . catch ( cb ) . then ( ( ) => cb ( ) ) ;
315
+ } else {
316
+ return promise ;
317
+ }
297
318
} ;
298
319
299
320
util . inherits ( Worker , EventEmitter ) ;
Original file line number Diff line number Diff line change @@ -131,6 +131,7 @@ test.serial('Step function Activity Worker with 200 parallel tasks and heartbeat
131
131
return new Promise ( ( resolve , reject ) => {
132
132
worker . once ( 'empty' , ( ) => {
133
133
t . is ( count , totalTasks ) ;
134
+ t . true ( countFull > 0 ) ;
134
135
// T.is(Math.abs(countFull - (totalTasks-taskConcurrency))/totalTasks)
135
136
const endDate = new Date ( ) ;
136
137
worker . logger . info ( `Spent ${ ( endDate - startDate ) / 1000 } seconds` ) ;
Original file line number Diff line number Diff line change @@ -197,7 +197,9 @@ test.serial('Restart the worker', t => {
197
197
198
198
if ( countSuccess === 1 ) {
199
199
const beforeRestartLength = worker . _poolers . length ;
200
+ console . log ( 'restart' ) ;
200
201
worker . restart ( ( ) => {
202
+ console . log ( 'restarted' ) ;
201
203
t . is ( worker . _poolers . length , beforeRestartLength ) ;
202
204
stepFunction . startExecution ( params2 ) . promise ( ) ;
203
205
} ) ;
You can’t perform that action at this time.
0 commit comments