{ "info": { "author": "Eric ALBER", "author_email": "eric.alber@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: MacOS X :: Cocoa", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Programming Language :: Python" ], "description": "# CoreFoundation based selector and asyncio event loop\n\n## asyncio event loop\n\nOn macOS X, Cocoa uses an event loop to dispatch events ([`NSRunLoop`](https://developer.apple.com/documentation/foundation/nsrunloop), which is a wrapper around [`CFRunLoop`](https://developer.apple.com/documentation/corefoundation/cfrunloop?language=objc)).\n\nPython's [asyncio](https://docs.python.org/3/library/asyncio.html) module uses an event loop too to handle asynchronous events. On macOS X, it's based on [kqueue](https://docs.python.org/3/library/selectors.html#selectors.KqueueSelector).\n\nA thread can only use a single event loop, that's why it's not possible to use both Cocoa and asyncio on the same thread. This module implements an asyncio compatible event loop on top of CFRunLoop. Thus it's possible to use Cocoa in conjunction with asyncio.\nIt uses internally PyObjC's [`runEventLoop`](https://pyobjc.readthedocs.io/en/latest/api/module-PyObjCTools.AppHelper.html) or [`runConsoleEventLoop`](https://pyobjc.readthedocs.io/en/latest/api/module-PyObjCTools.AppHelper.html)\n\nHere is an example video of a simple Cocoa based GUI using `asyncio` and `async`/`await` to handle subprocesses and network calls:\n\n[![Example video](https://img.youtube.com/vi/-Arl0-7y7so/0.jpg)](https://www.youtube.com/watch?v=-Arl0-7y7so)\n\nThe corresponding code is here: [tests/gui/guidemo.py](https://github.com/alberthier/corefoundationasyncio/blob/master/tests/gui/guidemo.py)\n\nSetup:\n\n```python\n loop = CoreFoundationEventLoop()\n asyncio.set_event_loop(loop)\n try:\n loop.run_forever()\n finally:\n loop.close()\n```\n\n`CoreFoundationEventLoop`'s constructor's first argument is a boolean. `True` for a console app, `False` (default) for a GUI app.\nAdditionnal arguments are then passed to [`PyObjCTools.AppHelper.runConsoleEventLoop`](https://pyobjc.readthedocs.io/en/latest/api/module-PyObjCTools.AppHelper.html) or [`PyObjCTools.AppHelper.runEventLoop`](https://pyobjc.readthedocs.io/en/latest/api/module-PyObjCTools.AppHelper.html)\n\n## selector\n\nThis module also provides a [selector](https://docs.python.org/3/library/selectors.html) implementation based on [CFRunLoop](https://developer.apple.com/documentation/corefoundation/cfrunloop?language=objc). But his selector isn't compatible with Cocoa GUIs\n\n## Installation\n\n```shell\n$ pip3 install corefoundationasyncio\n```\n\nThis module depends on [pyobjc](https://pypi.org/project/pyobjc/)\n\n## Contributing\n\nReport issues [here](https://github.com/alberthier/corefoundationasyncio/issues)\n\nPull-requests welcome !\n\n## License\n\nThis software is licensed under the [MIT](LICENSE) license", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alberthier/corefoundationasyncio", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "corefoundationasyncio", "package_url": "https://pypi.org/project/corefoundationasyncio/", "platform": "", "project_url": "https://pypi.org/project/corefoundationasyncio/", "project_urls": { "Homepage": "https://github.com/alberthier/corefoundationasyncio" }, "release_url": "https://pypi.org/project/corefoundationasyncio/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "CoreFoundation based selector and asyncio event loop", "version": "0.0.1" }, "last_serial": 5304884, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "882ff9d4acba84f71bae9cd24102a196", "sha256": "8053494f0c7c3cb1feb35484423039fa6f4ddfe278a2cc5520d4ff2920f0ad01" }, "downloads": -1, "filename": "corefoundationasyncio-0.0.1.tar.gz", "has_sig": false, "md5_digest": "882ff9d4acba84f71bae9cd24102a196", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4587, "upload_time": "2019-05-22T22:58:28", "url": "https://files.pythonhosted.org/packages/43/ab/888771f58dd20a9350e446a470eb046ee0085f0aaee198d4b4da6f5e2ec3/corefoundationasyncio-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "882ff9d4acba84f71bae9cd24102a196", "sha256": "8053494f0c7c3cb1feb35484423039fa6f4ddfe278a2cc5520d4ff2920f0ad01" }, "downloads": -1, "filename": "corefoundationasyncio-0.0.1.tar.gz", "has_sig": false, "md5_digest": "882ff9d4acba84f71bae9cd24102a196", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4587, "upload_time": "2019-05-22T22:58:28", "url": "https://files.pythonhosted.org/packages/43/ab/888771f58dd20a9350e446a470eb046ee0085f0aaee198d4b4da6f5e2ec3/corefoundationasyncio-0.0.1.tar.gz" } ] }