Skip to content

Commit

Permalink
feat: return full results from result processing
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Mar 8, 2024
1 parent f221b7d commit f0cdb26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions nvchecker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import structlog

from . import core
from .util import VersData, RawResult, KeyManager, EntryWaiter
from .util import VersData, RawResult, Result, KeyManager, EntryWaiter
from .ctxvars import proxy as ctx_proxy

logger = structlog.get_logger(logger_name=__name__)
Expand Down Expand Up @@ -80,10 +80,10 @@ 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))
newvers, 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))
newvers, 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]
Expand All @@ -95,7 +95,7 @@ def main() -> None:
sys.exit(3)

async def run(
result_coro: Coroutine[None, None, Tuple[VersData, bool]],
result_coro: Coroutine[None, None, Tuple[VersData, List[Result], bool]],
runner_coro: Coroutine[None, None, None],
) -> Tuple[VersData, bool]:
result_fu = asyncio.create_task(result_coro)
Expand Down
6 changes: 4 additions & 2 deletions nvchecker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ async def process_result(
result_q: Queue[RawResult],
entry_waiter: EntryWaiter,
log_noop: bool = False,
) -> Tuple[VersData, bool]:
) -> Tuple[VersData, List[Result], bool]:
ret = {}
results = []
has_failures = False
try:
while True:
Expand All @@ -414,8 +415,9 @@ async def process_result(
check_version_update(oldvers, r1, log_noop)
entry_waiter.set_result(r1.name, r1.version)
ret[r1.name] = r1.version
results.append(r1)
except asyncio.CancelledError:
return ret, has_failures
return ret, results, has_failures

async def run_tasks(
futures: Sequence[Awaitable[None]]
Expand Down

0 comments on commit f0cdb26

Please sign in to comment.