From ef1fa591e569d8bcaf7848a8230dab67eda96244 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sun, 12 Jun 2016 13:45:57 +0000 Subject: [PATCH] Slightly improved error handling, some heuristics for number of cores to build with, and misc. work in progress changes. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3246 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- core/terminal.js | 8 +++++++- packages/cory/chat/chat.js | 7 ++++++- packages/cory/libchat/libchat.js | 7 ++++++- tools/update-deps | 11 +++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/core/terminal.js b/core/terminal.js index a1d4b9a6..a7159ac2 100644 --- a/core/terminal.js +++ b/core/terminal.js @@ -121,7 +121,13 @@ function invoke(handlers, argv) { var promises = []; if (handlers) { for (var i = 0; i < handlers.length; ++i) { - promises.push(handlers[i].apply({}, argv)); + try { + promises.push(handlers[i].apply({}, argv)); + } catch (error) { + handlers.splice(i, 1); + i--; + promises.push(new Promise(function(resolve, reject) { reject(error); })); + } } } return Promise.all(promises); diff --git a/packages/cory/chat/chat.js b/packages/cory/chat/chat.js index c3d85163..a5521bf3 100644 --- a/packages/cory/chat/chat.js +++ b/packages/cory/chat/chat.js @@ -233,6 +233,11 @@ function updateWindows() { function updateConversation() { if (gCurrentConversation) { + terminal.cork(); + terminal.clear(); + terminal.print("..."); + terminal.uncork(); + Promise.all([ gCurrentConversation.session.getHistory(gCurrentConversation.name), gCurrentConversation.session.getParticipants(gCurrentConversation.name), @@ -405,7 +410,7 @@ function formatMessage(message) { var result; if (typeof message == "string") { for (let i = 0; i < message.length; i++) { - if (message.charCodeAt(i) > 128 && message.charCodeAt(i) < 256) { + if (message.charCodeAt(i) >= 128 /*&& message.charCodeAt(i) < 256*/) { message = message.substring(0, i) + "?" + message.substring(i + 1); } } diff --git a/packages/cory/libchat/libchat.js b/packages/cory/libchat/libchat.js index d8a3c0d0..df28d1d7 100644 --- a/packages/cory/libchat/libchat.js +++ b/packages/cory/libchat/libchat.js @@ -48,7 +48,12 @@ exports.ChatService = class { for (let i = self._callbacks.length - 1; i >= 0; i--) { let callback = self._callbacks[i]; try { - callback(message); + callback(message).catch(function(error) { + self._callbacks.splice(i, 1); + + // XXX: Send it to the other connections? + print(error); + }); } catch (error) { self._callbacks.splice(i, 1); diff --git a/tools/update-deps b/tools/update-deps index a8002a9b..de57aa67 100755 --- a/tools/update-deps +++ b/tools/update-deps @@ -1,6 +1,8 @@ #!/usr/bin/python -u +import multiprocessing import os +import platform import shutil import stat import subprocess @@ -26,6 +28,11 @@ kV8Repository = 'https://github.com/v8/v8.git' kV8Branch = 'branch-heads/5.1' kV8Work = 'v8' +cores = multiprocessing.cpu_count() +if platform.machine() == 'armv7l': + cores = 1 +print 'Using', cores, 'cores.' + def run(*args, **kw): print 'Running:', args, kw subprocess.check_call(*args, **kw) @@ -63,7 +70,7 @@ def updateUv(): if sys.platform == 'linux2': run(['./gyp_uv.py', '-f', 'make'], cwd=kUvWork) - run(['make', '-j8', '-C', 'out'], cwd=kUvWork) + run(['make', '-j' + str(cores), '-C', 'out'], cwd=kUvWork) elif sys.platform == 'darwin': run(['./gyp_uv.py', '-f', 'xcode'], cwd=kUvWork) run(['xcodebuild', '-ARCHS="x86_64"', '-project', 'uv.xcodeproj', '-configuration', 'Release', '-target', 'All'], cwd=kUvWork) @@ -116,7 +123,7 @@ def updateV8(): run(['gclient' + extension, 'sync'], cwd=kV8Work) if sys.platform == 'linux2': - run(['make', '-j4', 'native'], cwd=kV8Work) + run(['make', '-j' + str(cores), 'native'], cwd=kV8Work) elif sys.platform == 'darwin': run(['build/gyp_v8', '-Dtarget_arch=x64'], cwd=kV8Work) run(['xcodebuild', '-project', 'build/all.xcodeproj', '-configuration', 'Release'], cwd=kV8Work)