toga icon indicating copy to clipboard operation
toga copied to clipboard

`DeprecationWarning` for Python 3.14: `Custom EventLoopPolicy`

Open kattni opened this issue 6 months ago • 5 comments

Describe the bug

A DeprecationWarning for Python 3.14 is currently being encountered with usage of Toga through briefcase run.

Steps to reproduce

  1. Run briefcase run with Toga 0.5.1 installed.
  2. The following warning is displayed:
beeware-tutorial/helloworld/build/helloworld/macos/app/Hello World.app/Contents/Resources/
app_packages/toga_cocoa/app.py:108: DeprecationWarning: Custom EventLoopPolicy instances
have been deprecated by Python 3.14. Create and use a `RubiconEventLoop` instance directly
instead of installing an event loop policy and calling `asyncio.new_event_loop()`.
  asyncio.set_event_loop_policy(EventLoopPolicy())

Expected behavior

Toga update is needed to resolve this.

Screenshots

No response

Environment

  • Operating System: MacOS
  • Python version: Python 3.13
  • Software versions:
    • Briefcase: 0.3.23
    • Toga: 0.5.1

Logs


Additional context

No response

kattni avatar Jun 05 '25 03:06 kattni

Thanks for the report. This has been triggered by the release of Rubicon ObjC 0.5.1; the fix is that Toga needs to do exactly what the warning advises.

There's likely an analogous change to be made for the GTK backend (cc @danyeaw), as it currently constructs a GLibEventLoopPolicy(). I don't know if that will need a fix upstream in PyGObject, but something will be needed to maintain Py3.14 support without warnings.

freakboy3742 avatar Jun 05 '25 03:06 freakboy3742

Fixed in #3532

freakboy3742 avatar Jun 05 '25 09:06 freakboy3742

https://github.com/beeware/toga/pull/3532 only fixes this for macOS and iOS, so I'll rename the issue to indicate that it only applies to GTK.

mhsmith avatar Jun 05 '25 09:06 mhsmith

Thanks for tagging me on this, I've opened https://gitlab.gnome.org/GNOME/pygobject/-/issues/697 to track fixing this in PyGObject.

danyeaw avatar Jun 08 '25 23:06 danyeaw

I think this might affect Windows as well. The fix there will be entirely on the Toga side (as we're the one providing the Proactor event loop) - but we won't be able to test/evaluate this until Python.net supports 3.14.

freakboy3742 avatar Jun 09 '25 00:06 freakboy3742