I’ve been working on an asyncio eventloop for PyObjC on and of over the last couple of months. This has finally resulted in an initial release (1.0b1) on PyPI: objc_asyncio.
The code is complete, with proper test coverage, but I haven’t seriously used the library yet which is why I’ve started out with a beta release. For now the library requires Python 3.8 or 3.9, support for 3.7 is on my roadmap.
To use asyncio in a Cocoa GUI:
import sys
import Cocoa
import objc_asyncio
with objc_asyncio.running_loop():
Cocoa.NSApplicationMain(sys.argv)
The, fairly minimal, documentation is found at read the docs, although the regular asyncio documentation and resources should be used to learn how to use asyncio.
Installation:
$ python3.8 -m pip install --pre objc_asyncio
This has taken more time than I’d expected up front, it didn’t help that I basically didn’t know asyncio before I started.
I’m not entirely happy with the amount of code in the library, I had to clone a lot of standard library code because the builtin loops assume that Python is in control of the eventloop itself and because I try to avoid depending on private APIs. Luckily it was possible to keep a clear separation between my own code and code cloned from asyncio.