objc_asyncio - asyncio support for PyObjC

The library “objc_asyncio” contains the implementation of an asyncio eventloop on top of the Cocoa eventloop library (in particular CFRunLoop), which makes it easy to use asyncio in Cocoa GUIs on macOS.

The library also contains a number of utilities to make using asyncio in Cocoa GUIs easier.

Release information

Objc_asyncio 0.1 is not yet released. See the changelog for information on this release.

Installation

The library can be installed using pip. Installing does not require a compiler.

Supported platforms

This package supports Python 3.7 and later on macOS 10.9 or later, it is not supported on other platforms like iOS, Windows and Linux.

This package requires a working ssl module.

Basic Usage

Interative use

To experiment with objc_asyncio you can use an interactive interpreter with asyncio support:

In command-line scripts

Call objc_asyncio.install() before calling asyncio.run() or manually creating an asyncio event loop:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
 import asyncio
 import objc_asyncio

 objc_asyncio.install()

 async def main():
     ...


 asyncio.run(main())

In GUI programs

Call objc_asyncio.install() before starting the main GUI:

1
2
3
4
5
6
7
 import sys
 import Cocoa

 import objc_asyncio

 with objc_asyncio.running_loop():
     Cocoa.NSApplicationMain(sys.argv)

Indices and tables