Skip to content

Commit

Permalink
B0.2 (#65)
Browse files Browse the repository at this point in the history
* Sign new agreements only if there are unassigned tasks (#76)

* Sign new agreements only if there are unassigned tasks
* Display a nice message when the computation is interrupted

* Update package.json

* version bump

Co-authored-by: filipgolem <44880692+filipgolem@users.noreply.github.com>
Co-authored-by: Filip <filip@golem.network>
Co-authored-by: Muhammed Tanrikulu <md.tanrikulu@gmail.com>
  • Loading branch information
4 people committed Dec 8, 2020
1 parent ba77291 commit d0c2149
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bluebird": "^3.5.0",
"dayjs": "^1.8.31",
"ts-node": "^9.0.0",
"yajsapi": "^0.2.0"
"yajsapi": "^0.2.1"
},
"devDependencies": {
"tsconfig-paths": "^3.9.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yajsapi",
"version": "0.2.0",
"version": "0.2.1",
"description": "NodeJS API for Next Golem",
"repository": "https://github.com/golemfactory/yajsapi",
"main": "dist/index.js",
Expand Down
9 changes: 7 additions & 2 deletions yajsapi/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ export class Engine {
await sleep(2);
if (
Object.keys(offer_buffer).length > 0 &&
workers.size < self._conf.max_workers
workers.size < self._conf.max_workers &&
work_queue.has_unassigned_items()
) {
let _offer_list = Object.entries(offer_buffer);
let _sample =
Expand Down Expand Up @@ -713,7 +714,11 @@ export class Engine {
}
emit(new events.ComputationFinished());
} catch (error) {
logger.error(`fail= ${error}`);
if (error === undefined) { // this needs more research
logger.error("Computation interrupted by the user.");
} else {
logger.error(`fail= ${error}`);
}
if (!self._worker_cancellation_token.cancelled)
self._worker_cancellation_token.cancel();
// TODO: implement ComputationFinished(error)
Expand Down
4 changes: 4 additions & 0 deletions yajsapi/runner/smartq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export class SmartQueue<Item> {
await promisify(csp.takeAsync)(this.__eof);
}
}

has_unassigned_items(): boolean {
return !!(this._items && this._items.length) || !!this._rescheduled_items.size
}
}

export class Consumer<Item> {
Expand Down

0 comments on commit d0c2149

Please sign in to comment.