Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yield completed tasks from Engine.map() #44

Merged
merged 4 commits into from
Sep 30, 2020

Conversation

azawlocki
Copy link
Contributor

@azawlocki azawlocki commented Sep 24, 2020

Resolves #26

  • Engine.map() now yields completed tasks. Its return type is now AsyncIterator[Task[D, R]], where D and R are type variables representing task data and results, respectively.

  • The Task class is in a separate module yapapi.runner.task.

@azawlocki azawlocki marked this pull request as draft September 24, 2020 06:41
@azawlocki azawlocki changed the base branch from master to refactor/typed-events September 24, 2020 06:42
@@ -329,7 +324,7 @@ async def find_offers():
await proposal.respond(builder.props, builder.cons)
emit(Event.ProposalResponded(prop_id=proposal.id))
except Exception as ex:
emit(Event.ProposalFailed(sub_id=subscription.id, reason=str(ex)))
emit(Event.ProposalFailed(prop_id=proposal.id, reason=str(ex)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error has been reported by mypy but only after I added a return type annotation to def find_offers().

@@ -409,8 +404,8 @@ async def worker_starter():
task = None
try:
agreement = await b.proposal.agreement()
provider_id = (await agreement.details()).view_prov(Identification)
emit(Event.AgreementCreated(agr_id=agreement.id, provider_id=provider_id))
prov_idn = (await agreement.details()).view_prov(Identification)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provider_id = ... shadowed another declaration with a different type

):
if datetime.now(timezone.utc) > self._expires:
raise TimeoutError(f"task timeout exceeded. timeout={self._conf.timeout}")

if not get_done_task:
get_done_task = loop.create_task(done_queue.get())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (asyncio) task just removes a single completed (yapapi) task from done_queue.

@@ -508,113 +516,11 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
await self._stack.aclose()


class TaskStatus(Enum):
Copy link
Contributor Author

@azawlocki azawlocki Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has been moved to yapapi/runner/task.py

@azawlocki azawlocki self-assigned this Sep 25, 2020
@azawlocki azawlocki linked an issue Sep 25, 2020 that may be closed by this pull request
@azawlocki azawlocki force-pushed the refactor/typed-events branch 2 times, most recently from e9a2310 to d005c4d Compare September 29, 2020 07:38
@azawlocki azawlocki marked this pull request as ready for review September 30, 2020 07:48
@azawlocki azawlocki changed the base branch from refactor/typed-events to master September 30, 2020 08:03
@azawlocki azawlocki force-pushed the refactor/yield-completed-tasks branch 2 times, most recently from 8b6de25 to 89226f5 Compare September 30, 2020 15:16
@azawlocki azawlocki merged commit 40f1474 into master Sep 30, 2020
@shadeofblue shadeofblue deleted the refactor/yield-completed-tasks branch September 30, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yield completed tasks from `Engine.map()
2 participants