mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
feat: return full results from result processing
This commit is contained in:
parent
9dd7fb1736
commit
f29bdee6a3
4 changed files with 12 additions and 10 deletions
|
@ -13,7 +13,7 @@ from pathlib import Path
|
|||
import structlog
|
||||
|
||||
from . import core
|
||||
from .util import VersData, RawResult, KeyManager, EntryWaiter
|
||||
from .util import ResultData, RawResult, KeyManager, EntryWaiter
|
||||
from .ctxvars import proxy as ctx_proxy
|
||||
|
||||
logger = structlog.get_logger(logger_name=__name__)
|
||||
|
@ -80,24 +80,24 @@ def main() -> None:
|
|||
|
||||
if sys.version_info >= (3, 10):
|
||||
# Python 3.10 has deprecated asyncio.get_event_loop
|
||||
newvers, has_failures = asyncio.run(run(result_coro, runner_coro))
|
||||
results, has_failures = asyncio.run(run(result_coro, runner_coro))
|
||||
else:
|
||||
# Python < 3.10 will create an eventloop when asyncio.Queue is initialized
|
||||
newvers, has_failures = asyncio.get_event_loop().run_until_complete(run(result_coro, runner_coro))
|
||||
results, has_failures = asyncio.get_event_loop().run_until_complete(run(result_coro, runner_coro))
|
||||
|
||||
if options.ver_files is not None:
|
||||
newverf = options.ver_files[1]
|
||||
vers = core.read_verfile(newverf)
|
||||
vers.update(newvers)
|
||||
vers.update({k: r.version for k, r in results.items()})
|
||||
core.write_verfile(newverf, vers)
|
||||
|
||||
if args.failures and has_failures:
|
||||
sys.exit(3)
|
||||
|
||||
async def run(
|
||||
result_coro: Coroutine[None, None, Tuple[VersData, bool]],
|
||||
result_coro: Coroutine[None, None, Tuple[ResultData, bool]],
|
||||
runner_coro: Coroutine[None, None, None],
|
||||
) -> Tuple[VersData, bool]:
|
||||
) -> Tuple[ResultData, bool]:
|
||||
result_fu = asyncio.create_task(result_coro)
|
||||
runner_fu = asyncio.create_task(runner_coro)
|
||||
await runner_fu
|
||||
|
|
|
@ -394,7 +394,7 @@ async def process_result(
|
|||
result_q: Queue[RawResult],
|
||||
entry_waiter: EntryWaiter,
|
||||
verbose: bool = False,
|
||||
) -> Tuple[VersData, bool]:
|
||||
) -> Tuple[ResultData, bool]:
|
||||
ret = {}
|
||||
has_failures = False
|
||||
try:
|
||||
|
@ -411,7 +411,7 @@ async def process_result(
|
|||
continue
|
||||
check_version_update(oldvers, r1, verbose)
|
||||
entry_waiter.set_result(r1.name, r1.version)
|
||||
ret[r1.name] = r1.version
|
||||
ret[r1.name] = r1
|
||||
except asyncio.CancelledError:
|
||||
return ret, has_failures
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ class Result(NamedTuple):
|
|||
gitref: Optional[str]
|
||||
revision: Optional[str]
|
||||
|
||||
ResultData = Dict[str, Result]
|
||||
|
||||
class BaseWorker:
|
||||
'''The base class for defining `Worker` classes for source plugins.
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ async def run(
|
|||
result_coro = core.process_result(oldvers, result_q, entry_waiter)
|
||||
runner_coro = core.run_tasks(futures)
|
||||
|
||||
vers, _has_failures = await main.run(result_coro, runner_coro)
|
||||
return vers
|
||||
results, _has_failures = await main.run(result_coro, runner_coro)
|
||||
return {k: r.version for k, r in results.items()}
|
||||
|
||||
@pytest_asyncio.fixture(scope="session")
|
||||
async def get_version():
|
||||
|
|
Loading…
Add table
Reference in a new issue