Remove mandatory nursery argument
This commit is contained in:
parent
6cd445e54d
commit
0b16ed953e
@ -1,3 +1,7 @@
|
||||
# trio-gtk 1.0.0 (2020-09-21)
|
||||
|
||||
- Remove mandatory `nursery` argument for trio main.
|
||||
|
||||
# trio-gtk 0.1.1 (2020-09-20)
|
||||
|
||||
- Fix traceback handling on `done_callback`.
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
## Trio guest mode wrapper for PyGTK
|
||||
|
||||
Using the [Trio guest mode](https://trio.readthedocs.io/en/latest/reference-lowlevel.html#using-guest-mode-to-run-trio-on-top-of-other-event-loops) feature, we can run both the Trio and PyGTK event loops alongside each other in a single program. This allows us to make use of the Trio library and the usual `async`/`await` syntax and not have to directly manage thread pools.
|
||||
|
||||
This library provides a thin wrapper for initialising the guest mode and exposes a single public API function, `trio_gtk.run` into which you can pass your Trio main function. This function must accept a `nursery` argument which can spawn child tasks for the duration of the host loop.
|
||||
Using the [Trio guest mode](https://trio.readthedocs.io/en/latest/reference-lowlevel.html#using-guest-mode-to-run-trio-on-top-of-other-event-loops) feature, we can run both the Trio and PyGTK event loops alongside each other in a single program. This allows us to make use of the Trio library and the usual `async`/`await` syntax and not have to directly manage thread pools. This library provides a thin wrapper for initialising the guest mode and exposes a single public API function, `trio_gtk.run` into which you can pass your Trio main function.
|
||||
|
||||
## Install
|
||||
|
||||
@ -51,8 +49,10 @@ class Example(gtk.Window):
|
||||
print(f"hi from task {count}")
|
||||
|
||||
|
||||
async def main(nursery):
|
||||
async def main():
|
||||
async with trio.open_nursery() as nursery:
|
||||
Example(nursery)
|
||||
await trio.sleep_forever()
|
||||
|
||||
|
||||
trio_gtk.run(main)
|
||||
|
@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "trio-gtk"
|
||||
version = "0.1.1"
|
||||
version = "1.0.0"
|
||||
description = "Trio guest mode wrapper for PyGTK"
|
||||
authors = ["decentral1se <lukewm@riseup.net>"]
|
||||
maintainers = ["decentral1se <lukewm@riseup.net>"]
|
||||
|
@ -15,12 +15,6 @@ __all__ = ["run"]
|
||||
def run(trio_main):
|
||||
"""Run Trio and PyGTK together."""
|
||||
|
||||
async def _trio_main():
|
||||
async with trio.open_nursery() as nursery:
|
||||
nursery.start_soon(trio_main, nursery)
|
||||
while gtk.main_level() != 0:
|
||||
await trio.sleep(1)
|
||||
|
||||
def done_callback(outcome):
|
||||
if isinstance(outcome, Error):
|
||||
exc = outcome.error
|
||||
@ -31,7 +25,7 @@ def run(trio_main):
|
||||
glib.idle_add(function)
|
||||
|
||||
trio.lowlevel.start_guest_run(
|
||||
_trio_main,
|
||||
trio_main,
|
||||
run_sync_soon_threadsafe=glib_schedule,
|
||||
done_callback=done_callback,
|
||||
host_uses_signal_set_wakeup_fd=True,
|
||||
|
Reference in New Issue
Block a user