Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resubmitting the script to the Python interpreter #73

Open
xozzslip opened this issue Jun 21, 2024 · 3 comments
Open

Resubmitting the script to the Python interpreter #73

xozzslip opened this issue Jun 21, 2024 · 3 comments

Comments

@xozzslip
Copy link

Context:
I run a Python script in a browser environment and need advice on how to resubmit it to the Python interpreter after making updates. Here’s how I currently handle it:
Original Script:

print("Hello World!")
while True:
    pass

Current Execution Method:
I execute this script in the browser using the following JavaScript code:

await python.terminal(["python", "-i", "-c", code]);

Issue:
After modifying the script, I need to reload and run the updated version. I was considering using the SIGKILL signal to terminate the existing session and then reinitialize it with the new script. However, I discovered that SIGKILL is not supported—only SIGINT is available.
Current Non-Working Code:

python.kernel.signal(SIGKILL); // SIGKILL is not supported
await python.init();
await python.terminal(["python", "-i", "-c", newCode]);  // Intended to resubmit the new version

Questions:

  1. Given that SIGKILL is not supported and only SIGINT is available, how can I effectively terminate the existing Python session and start a new one with the updated script?
  2. Is adding support for SIGKILL a good approach to this problem?
@williamstein
Copy link
Contributor

I was the only person that worked on this project, and I haven't had time to work on it for a while, so it's unlikely you'll get an answer here. Sorry about that.

@xozzslip
Copy link
Author

Sure, no problem. I will tinker with it myself. Thank you for your effort in this project, by the way.

@williamstein
Copy link
Contributor

You're welcome. I hope I can contribute to it again someday. In the meantime, if you figure out anything useful, please feel free to comment here or create a PR (e.g., improving docs, the README, etc.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants