Minor fixes
This commit is contained in:
@@ -51,8 +51,6 @@ class Host:
|
||||
|
||||
@classmethod
|
||||
def run_app(cls, func: Callable, *args, **kwargs):
|
||||
loop = cls.get_loop()
|
||||
|
||||
cls.run_start_tasks()
|
||||
cls.run_hosted_services()
|
||||
|
||||
@@ -61,8 +59,7 @@ class Host:
|
||||
if asyncio.iscoroutinefunction(func):
|
||||
app_task = asyncio.create_task(func(*args, **kwargs))
|
||||
else:
|
||||
loop = asyncio.get_running_loop()
|
||||
app_task = loop.run_in_executor(None, func, *args, **kwargs)
|
||||
app_task = cls.get_loop().run_in_executor(None, func, *args, **kwargs)
|
||||
|
||||
await asyncio.wait(
|
||||
[app_task, *cls._tasks.values()],
|
||||
@@ -73,11 +70,11 @@ class Host:
|
||||
finally:
|
||||
await cls._stop_all()
|
||||
|
||||
loop.run_until_complete(runner())
|
||||
cls.get_loop().run_until_complete(runner())
|
||||
|
||||
@classmethod
|
||||
def run(cls, func: Callable, *args, **kwargs):
|
||||
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)
|
||||
@@ -161,7 +161,7 @@ class ServiceProvider:
|
||||
implementations = []
|
||||
if typing.get_origin(service_type) == list:
|
||||
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
|
||||
|
||||
def get_service_types(self, service_type: Type[T]) -> list[Type[T]]:
|
||||
|
||||
Reference in New Issue
Block a user