Skip to content

Resubmitting the script to the Python interpreter #73

Open
@xozzslip

Description

@xozzslip

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions