mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-21 11:01:26 -05:00
same thread syncify (#1372)
Switch to using the new version of synclink with support for same thread syncify (and also correct types). Uses syncify to replace one use of `_unwrapped_remote`.
This commit is contained in:
@@ -37,9 +37,9 @@ export class InterpreterClient extends Object {
|
||||
/**
|
||||
* initializes the remote interpreter, which further loads the underlying
|
||||
* interface.
|
||||
* */
|
||||
*/
|
||||
async initializeRemote(): Promise<void> {
|
||||
await this._unwrapped_remote.loadInterpreter(this.config, this.stdio);
|
||||
await this._remote.loadInterpreter(this.config, Synclink.proxy(this.stdio));
|
||||
// await this._remote.loadInterpreter(this.config, Synclink.proxy(this.stdio));
|
||||
this.globals = this._remote.globals;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ export class PyScriptApp {
|
||||
const interpreter_cfg = this.config.interpreters[0];
|
||||
|
||||
const remote_interpreter = new RemoteInterpreter(interpreter_cfg.src);
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
const { port1, port2 } = new Synclink.FakeMessageChannel() as unknown as MessageChannel;
|
||||
port1.start();
|
||||
port2.start();
|
||||
Synclink.expose(remote_interpreter, port2);
|
||||
|
||||
@@ -94,15 +94,15 @@ export class RemoteInterpreter extends Object {
|
||||
* contain these files and is clearly the wrong
|
||||
* path.
|
||||
*/
|
||||
async loadInterpreter(config: AppConfig, stdio: Stdio): Promise<void> {
|
||||
async loadInterpreter(config: AppConfig, stdio: Synclink.Remote<Stdio & ProxyMarked>): Promise<void> {
|
||||
this.interface = Synclink.proxy(
|
||||
await loadPyodide({
|
||||
stdout: (msg: string) => {
|
||||
// TODO: add syncify when moved to worker
|
||||
stdio.stdout_writeline(msg);
|
||||
stdio.stdout_writeline(msg).syncify();
|
||||
},
|
||||
stderr: (msg: string) => {
|
||||
stdio.stderr_writeline(msg);
|
||||
stdio.stderr_writeline(msg).syncify();
|
||||
},
|
||||
fullStdLib: false,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user