One of my plans for a future version of PyObjC is to add pervasive support for asyncio. This will in the end result in two changes to PyObjC:
Add an implementation of an asyncio event loop that is implemented on top of Apple’s NSRunLoop and CFRunLoop
Add “async” methods to Cocoa classes too change callback style programming with completion handlers into more or less standard async Python code.
To experiment with the latter I’ve created a small and crude script that lets me call the geocoder from CoreLocation in an async manner:
async def main(adress):
coder = CoreLocation.CLGeocoder.alloc().init()
placemarks, error = await coder.geocodeAdressString_(address)
This looks a lot nicer than the usual callback based code.
A link to the full script:. Most of the linked to script is support code that should mostly go away when I get around to adding an asyncio event loop to PyObjC.