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

make the common part of start_worker indeed, common #496

Merged
merged 5 commits into from
Jun 28, 2021

Conversation

shadeofblue
Copy link
Contributor

No description provided.

@shadeofblue shadeofblue requested review from a team and azawlocki June 24, 2021 06:25
Copy link
Contributor

@azawlocki azawlocki left a comment

Choose a reason for hiding this comment

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

Nice! I don't have any suggestions, except maybe to also make emitting the WorkerFinished event part of the new start_worker, along the lines of:

async def start_worker(...):
   
    async def _worker(...):
        # no changes
        ...
   
    async def _wrapped_worker(agrement, node_info):
        self.emit(WorkerStarted(agreement.id))
        try:
            await _worker(agreement, node_info)
            self.emit(WorkerFinished(agreement.id)
        except Exception:
            self.emit(WorkerFinished(agreement.id, exc_info=sys.exc_info())
            raise
            
    return await job.agreements_pool.use_agreement(
        lambda agreement, node: loop.create_task(_wrapped_worker(agreement, node))
    )

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.

2 participants