[gjs/gnome-40: 29/30] testGObjectDestructionAccess: Ignore errors when creating many threads




commit dbe83cdd4df0d40ae241bfe7f1e48b958d27cdf9
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 4454ce1f..ddacb41e 100644
--- a/installed-tests/js/testGObjectDestructionAccess.js
+++ b/installed-tests/js/testGObjectDestructionAccess.js
@@ -450,7 +450,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]