You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/04/18 07:18:20 UTC

[openwhisk-wskdebug] 03/03: await shutdown promise so that Debugger.run() returns only after shutdown

This is an automated email from the ASF dual-hosted git repository.

alexkli pushed a commit to branch console-spinner
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git

commit 91bc1101d4185384e409741c69e6579a3de4a0b1
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Sat Apr 18 00:15:45 2020 -0700

    await shutdown promise so that Debugger.run() returns only after shutdown
---
 src/debugger.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/debugger.js b/src/debugger.js
index 3dd127e..e7d250b 100644
--- a/src/debugger.js
+++ b/src/debugger.js
@@ -191,7 +191,6 @@ class Debugger {
     async _run() {
         try {
             this.running = true;
-            this.shuttingDown = false;
 
             // main blocking loop
             // abort if this.running is set to false
@@ -262,10 +261,15 @@ class Debugger {
 
     async shutdown() {
         // avoid duplicate shutdown on CTRL+C
-        if (this.shuttingDown) {
-            return;
+        if (!this.shutdownPromise) {
+            this.shutdownPromise = this._shutdown();
         }
-        this.shuttingDown = true;
+
+        await this.shutdownPromise;
+        delete this.shutdownPromise;
+    }
+
+    async _shutdown() {
         const shutdownStart = Date.now();
 
         // only log this if we started properly