Skip to content

Commit

Permalink
fix: update creart
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramRipper committed Aug 4, 2023
1 parent 118845e commit b93c8e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ authors = [
]
requires-python = ">=3.8,<4.0"
dependencies = [
"graia-broadcast>=0.22.1,<0.23",
"graia-broadcast~=0.23.0",
"aiohttp~=3.8",
"pydantic~=1.9",
"typing-extensions>=4.4,<5.0",
"graia-amnesia~=0.7.0",
"creart-graia @ git+https://github.com/GraiaProject/creart-graia.git",
"launart~=0.6.2",
"launart>=0.6.4,<0.7",
"packaging>=23.0",
"creart~=0.3.0",
]
name = "graia-ariadne"
description = "Another elegant Python QQ Bot framework for mirai and mirai-api-http v2."
Expand Down Expand Up @@ -83,8 +83,8 @@ source = "file"
path = "src/graia/ariadne/__init__.py"

[build-system]
requires = ["pdm-pep517>=1.0.0"]
build-backend = "pdm.pep517.api"
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.black]
line-length = 110
Expand Down
2 changes: 1 addition & 1 deletion src/graia/ariadne/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def launch_blocking(cls, stop_signals: Iterable[signal.Signals] = (signal.SIGINT
raise ValueError("No account specified.")
cls._patch_launch_manager()
try:
cls.launch_manager.launch_blocking(loop=cls.service.loop, stop_signal=stop_signals)
cls.launch_manager.launch_blocking(stop_signal=stop_signals)
except asyncio.CancelledError:
logger.info("Launch manager exited.", style="red")

Expand Down
6 changes: 4 additions & 2 deletions src/graia/ariadne/console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
注意, 本实现并不 robust, 但是可以使用
"""

import asyncio
import contextlib
import importlib.metadata
from creart import it
import sys
from asyncio.events import AbstractEventLoop
from asyncio.tasks import Task
Expand Down Expand Up @@ -173,7 +175,7 @@ async def catch(self, interface: DispatcherInterface):
if interface.annotation is Broadcast:
return self.console.broadcast
if interface.annotation is AbstractEventLoop:
return self.console.broadcast.loop
return asyncio.get_running_loop()

while self.running:
try:
Expand Down Expand Up @@ -214,7 +216,7 @@ def start(self):
logger.remove(0)
self.handler_id = logger.add(StdoutProxy(raw=True)) # type: ignore

self.task = self.broadcast.loop.create_task(self.loop())
self.task = it(AbstractEventLoop).create_task(self.loop())

def stop(self):
"""提示 Console 停止, 非异步, 幂等"""
Expand Down
2 changes: 1 addition & 1 deletion src/graia/ariadne/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def catch(interface: DispatcherInterface):
return Ariadne.service.broadcast

if generic_issubclass(asyncio.AbstractEventLoop, interface.annotation):
return Ariadne.service.broadcast.loop
return Ariadne.service.loop

if generic_issubclass(Ariadne, interface.annotation):
return Ariadne.current()
Expand Down
2 changes: 1 addition & 1 deletion src/graia/ariadne/message/commander/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def push_pending(index: int, nxt: MatchNode[CommandEntry], params: Tuple[ChainCo
tasks: List[asyncio.Task] = []
for entry, param in execution:
commander_param_ctx.set(param)
tasks.append(self.broadcast.loop.create_task(self.broadcast.Executor(entry, dispatchers)))
tasks.append(asyncio.create_task(self.broadcast.Executor(entry, dispatchers)))
done, _ = await asyncio.wait(tasks)
for task in done:
if task.exception() and isinstance(task.exception(), PropagationCancelled):
Expand Down

0 comments on commit b93c8e6

Please sign in to comment.