[gjs: 2/3] testGObjectDestructionAccess: Ignore errors when creating many threads
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/3] testGObjectDestructionAccess: Ignore errors when creating many threads
- Date: Wed, 5 May 2021 20:36:43 +0000 (UTC)
commit e507492f1b52753bdeadf12a2d34180a7a6dda93
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed May 5 05:07:57 2021 +0200
testGObjectDestructionAccess: Ignore errors when creating many threads
Do not fail if we can't create a thread in idle, we may be out of
resources and this is not a failure for us.
So we can wait for allocated threads to finish before allocating other
instances (and go out of memory).
installed-tests/js/testGObjectDestructionAccess.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/installed-tests/js/testGObjectDestructionAccess.js
b/installed-tests/js/testGObjectDestructionAccess.js
index 7d4a560c..8019a672 100644
--- a/installed-tests/js/testGObjectDestructionAccess.js
+++ b/installed-tests/js/testGObjectDestructionAccess.js
@@ -706,7 +706,14 @@ describe('GObject with toggle references', function () {
let threads = [];
ids.push(GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
threads = threads.slice(-50);
- threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 1));
+ try {
+ threads.push(GjsTestTools.delayed_ref_unref_other_thread(file, 1));
+ } catch (e) {
+ // If creating the thread failed we're almost going out of memory
+ // so let's first wait for the ones allocated to complete.
+ threads.forEach(th => th.join());
+ threads = [];
+ }
return true;
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]