Merge pull request #6618 from matham/patch-1

Don't preset async_sleep
This commit is contained in:
matham 2019-11-21 23:13:35 -05:00 committed by GitHub
commit fd7e81ef82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -154,8 +154,6 @@ class UnitKivyApp(object):
def __init__(self, **kwargs):
super().__init__(**kwargs)
from kivy.clock import Clock
self.async_sleep = Clock._async_lib.sleep
def started_app(*largs):
self.app_has_started = True
@ -165,11 +163,14 @@ class UnitKivyApp(object):
self.app_has_stopped = True
self.fbind('on_stop', stopped_app)
async def async_run(self, async_lib=None):
def set_async_lib(self, async_lib):
from kivy.clock import Clock
if async_lib is not None:
Clock.init_async_lib(async_lib)
self.async_sleep = Clock._async_lib.sleep
async def async_run(self, async_lib=None):
self.set_async_lib(async_lib)
return await super(UnitKivyApp, self).async_run(async_lib=async_lib)
def resolve_widget(self, base_widget=None):

View File

@ -73,6 +73,7 @@ async def kivy_app(request, nursery):
Window.canvas.clear()
app = request.param[0]()
app.set_async_lib(async_lib)
if async_lib == 'asyncio':
import asyncio
@ -80,6 +81,8 @@ async def kivy_app(request, nursery):
loop.create_task(app.async_run())
else:
nursery.start_soon(app.async_run)
from kivy.clock import Clock
Clock._max_fps = 0
ts = time.perf_counter()
while not app.app_has_started: