You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`BasicCrawler.stop()` calls asynchronous functions without awaiting
them, which can cause unexpected race conditions. This PR ensures that
multiple `.stop()` calls only result in one `AutoscaledPool.abort()`
call and that the `.stop()`-induced promises are resolved before the
main `BasicCrawler.run()` call resolves.
Closes#3257
* To stop the crawler immediately, use {@apilink BasicCrawler.teardown|`crawler.teardown()`} instead.
1081
1103
*/
1082
-
stop(message='The crawler has been gracefully stopped.'): void{
1083
-
// Gracefully starve the this.autoscaledPool, so it doesn't start new tasks. Resolves once the pool is cleared.
1084
-
this.autoscaledPool
1085
-
?.pause()
1086
-
// Resolves the `autoscaledPool.run()` promise in the `BasicCrawler.run()` method. Since the pool is already paused, it resolves immediately and doesn't kill any tasks.
1087
-
.then(async()=>this.autoscaledPool?.abort())
1088
-
.then(()=>this.log.info(message))
1089
-
.catch((err)=>{
1090
-
this.log.error('An error occurred when stopping the crawler:',err);
1091
-
});
1104
+
stop(reason='The crawler has been gracefully stopped.'): void{
0 commit comments