Skip to content

Commit

Permalink
use the main worker in ringo shell instead of a separate new worker
Browse files Browse the repository at this point in the history
reason: when loading a module in interactive mode (i.e. `ringo -i mymodule.js`) the module would be evaluated
using the main worker, but any calls of the module methods would be executed in the shell worker, which is
a different one. this makes using eg. `setTimeout` in module methods impossible because they fail with
`Current thread worker differs from scope worker` exception
  • Loading branch information
grob committed Jan 12, 2022
1 parent 823797c commit 3501410
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/org/ringojs/tools/RingoShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.ringojs.engine.RingoConfig;
import org.ringojs.engine.RingoWorker;
import org.ringojs.engine.ScriptError;
import org.ringojs.repository.Repository;
import org.mozilla.javascript.*;
import org.mozilla.javascript.tools.ToolErrorReporter;
import org.ringojs.repository.Resource;
Expand All @@ -45,8 +44,6 @@
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.security.CodeSource;
import java.security.CodeSigner;

/**
* RingoShell is a simple interactive shell that provides the
Expand All @@ -60,7 +57,6 @@ public class RingoShell {
Scriptable scope;
boolean silent;
Path history;
CodeSource codeSource = null;
final String PROMPT = ">> ";
final String SECONDARY_PROMPT = ".. ";

Expand All @@ -73,7 +69,7 @@ public RingoShell(RhinoEngine engine, Path history, boolean silent)
this.config = engine.getConfig();
this.engine = engine;
this.history = history;
this.worker = engine.getWorker();
this.worker = engine.getMainWorker();
this.scope = engine.getShellScope(worker);
this.silent = silent;
}
Expand Down

0 comments on commit 3501410

Please sign in to comment.