Skip to content

Bug: Cocoa SIGINT handler uses shutdown path that doesn't allow Python's atexit to run #1796

@mikez

Description

@mikez

I asked an LLM agent to summarize the issue, including providing an example to reproduce.

System: macOS, Cocoa.

import atexit

import webview


def proof():
    with open("/tmp/atexit_proof.txt", "w") as f:
        f.write("atexit ran")


atexit.register(proof)

window = webview.create_window("Test", html="<h1>Test</h1>")
webview.start()

Close via X → /tmp/atexit_proof.txt exists. Close via Ctrl+C → it doesn't exist.

Using Cocao, Ctrl+C terminates the app, but it terminates via NSApp().terminate_() at the Cocoa level, which never returns to Python. Compare this to the QT backend which calls _app.quit() — that exits the Qt event loop and returns control to Python, allowing normal shutdown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions