Skip to content

Instantly share code, notes, and snippets.

@bct
Created February 13, 2024 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bct/d50aa3a07320de070bdba9b21b096b2a to your computer and use it in GitHub Desktop.
Save bct/d50aa3a07320de070bdba9b21b096b2a to your computer and use it in GitHub Desktop.
jspybridge memory growth example
const EventEmitter = require("node:events");
const emitter = new EventEmitter();
const sleep = (waitTimeInMs) =>
new Promise((resolve) => setTimeout(resolve, waitTimeInMs));
async function doLoop() {
while (true) {
emitter.emit("ping", new Date().toISOString());
// sleep 50ms
await sleep(50);
}
}
doLoop();
module.exports = {
emitter,
};
import datetime
import time
from javascript import On, require
print("loading")
my_module = require("./test-bridge.js")
@On(my_module.emitter, "ping")
def _ping(emitter: ..., now: str):
print(f"pong {now} {datetime.datetime.now().time()}")
# Keep the Python process alive
time.sleep(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment