Skip to content

Commit

Permalink
adapt to asyncgui 0.6.2, and publish asynckivy 0.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gottadiveintopython committed Jun 21, 2024
1 parent bb1deec commit 5db53fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "asynckivy"
version = "0.6.2"
version = "0.6.3"
description = "Async library for Kivy"
authors = ["Nattōsai Mitō <flow4re2c@gmail.com>"]
license = "MIT"
Expand Down
12 changes: 6 additions & 6 deletions src/asynckivy/_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import typing as T
from functools import partial
from asyncgui import IBox
from asyncgui import AsyncEvent


async def event(event_dispatcher, event_name, *, filter=None, stop_dispatching=False) -> T.Awaitable[tuple]:
Expand Down Expand Up @@ -40,16 +40,16 @@ async def event(event_dispatcher, event_name, *, filter=None, stop_dispatching=F
It only works for events not for properties.
See :ref:`kivys-event-system` for details.
'''
box = IBox()
bind_id = event_dispatcher.fbind(event_name, partial(_callback, filter, box, stop_dispatching))
ev = AsyncEvent()
bind_id = event_dispatcher.fbind(event_name, partial(_callback, filter, ev, stop_dispatching))
assert bind_id # check if binding succeeded
try:
return (await box.get())[0]
return (await ev.wait())[0]
finally:
event_dispatcher.unbind_uid(event_name, bind_id)


def _callback(filter, box, stop_dispatching, *args, **kwargs):
def _callback(filter, ev, stop_dispatching, *args, **kwargs):
if (filter is None) or filter(*args, **kwargs):
box.put(*args)
ev.fire(*args)
return stop_dispatching
4 changes: 2 additions & 2 deletions src/asynckivy/_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async def run_in_thread(func, *, daemon=None) -> T.Awaitable:
See :ref:`io-in-asynckivy` for details.
'''
box = asyncgui.IBox()
box = asyncgui.AsyncBox()
Thread(
name='asynckivy.run_in_thread',
target=_wrapper, daemon=daemon, args=(func, box, ),
Expand All @@ -51,7 +51,7 @@ async def run_in_executor(executor: ThreadPoolExecutor, func) -> T.Awaitable:
See :ref:`io-in-asynckivy` for details.
'''
box = asyncgui.IBox()
box = asyncgui.AsyncBox()
future = executor.submit(_wrapper, func, box)
try:
ret, exc = (await box.get())[0]
Expand Down

0 comments on commit 5db53fb

Please sign in to comment.