From 928ffc96e6d5ce29ce36235e6ac7bd3f52697269 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 11 Aug 2016 09:32:47 +0100 Subject: [PATCH] read wordcount output asynchronously --- app/coffee/CompileManager.coffee | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/coffee/CompileManager.coffee b/app/coffee/CompileManager.coffee index 39cff29..e3a218b 100644 --- a/app/coffee/CompileManager.coffee +++ b/app/coffee/CompileManager.coffee @@ -233,12 +233,11 @@ module.exports = CompileManager = CommandRunner.run compileName, command, directory, image, timeout, {}, (error) -> return callback(error) if error? - try - stdout = fs.readFileSync(directory + "/" + file_name + ".wc", "utf-8") - catch err - logger.err err:err, command:command, directory:directory, project_id:project_id, user_id:user_id, "error reading word count output" - return callback(err) - callback null, CompileManager._parseWordcountFromOutput(stdout) + fs.readFile directory + "/" + file_name + ".wc", "utf-8", (err, stdout) -> + if err? + logger.err err:err, command:command, directory:directory, project_id:project_id, user_id:user_id, "error reading word count output" + return callback(err) + callback null, CompileManager._parseWordcountFromOutput(stdout) _parseWordcountFromOutput: (output) -> results = {