WIP: dev into master #184

Draft
edraft wants to merge 121 commits from dev into master
2 changed files with 4 additions and 7 deletions
Showing only changes of commit ecb92fca3e - Show all commits

View File

@@ -51,8 +51,6 @@ class Host:
@classmethod @classmethod
def run_app(cls, func: Callable, *args, **kwargs): def run_app(cls, func: Callable, *args, **kwargs):
loop = cls.get_loop()
cls.run_start_tasks() cls.run_start_tasks()
cls.run_hosted_services() cls.run_hosted_services()
@@ -61,8 +59,7 @@ class Host:
if asyncio.iscoroutinefunction(func): if asyncio.iscoroutinefunction(func):
app_task = asyncio.create_task(func(*args, **kwargs)) app_task = asyncio.create_task(func(*args, **kwargs))
else: else:
loop = asyncio.get_running_loop() app_task = cls.get_loop().run_in_executor(None, func, *args, **kwargs)
app_task = loop.run_in_executor(None, func, *args, **kwargs)
await asyncio.wait( await asyncio.wait(
[app_task, *cls._tasks.values()], [app_task, *cls._tasks.values()],
@@ -73,11 +70,11 @@ class Host:
finally: finally:
await cls._stop_all() await cls._stop_all()
loop.run_until_complete(runner()) cls.get_loop().run_until_complete(runner())
@classmethod @classmethod
def run(cls, func: Callable, *args, **kwargs): def run(cls, func: Callable, *args, **kwargs):
if asyncio.iscoroutinefunction(func): if asyncio.iscoroutinefunction(func):
return cls._loop.run_until_complete(func(*args, **kwargs)) return cls.get_loop().run_until_complete(func(*args, **kwargs))
return func(*args, **kwargs) return func(*args, **kwargs)

View File

@@ -161,7 +161,7 @@ class ServiceProvider:
implementations = [] implementations = []
if typing.get_origin(service_type) == list: if typing.get_origin(service_type) == list:
raise Exception(f"Invalid type {service_type}! Expected single type not list of type") raise Exception(f"Invalid type {service_type}! Expected single type not list of type")
implementations.extend(self._get_services(service_type, None, *args, **kwargs)) implementations.extend(self._get_services(service_type, *args, **kwargs))
return implementations return implementations
def get_service_types(self, service_type: Type[T]) -> list[Type[T]]: def get_service_types(self, service_type: Type[T]) -> list[Type[T]]: