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

allow for Job class to have an __await__ method #512

Closed
wants to merge 10 commits into from

Conversation

Vizonex
Copy link

@Vizonex Vizonex commented Aug 24, 2024

I thought it would be a smart idea if the Job class could be something that could be optionally awaited on simply by just calling await in cases were code such as await job.wait() is not feasible and where we know in advance that we don't need a timeout variable inplace, this would allow for something such as asyncio.gather() to be easily done on a group of jobs to being awaited on rather than having to write a bunch of coroutines beforehand. This would make the job class more task-like since asyncio tasks have this same feature where they can be awaited simply by calling await task for instance. I have also written some unittests as well to for this library that would best demonstrate these examples.

Related issue number

I don't think this is related to any issues however I do believe that this idea would be helpful.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • [] Documentation reflects the changes

tests/test_job.py Outdated Show resolved Hide resolved
@Dreamsorcerer
Copy link
Member

Yeah, I think this seems reasonable.

@Dreamsorcerer
Copy link
Member

Except for all the issues that arise... So, maybe not..

@asvetlov
Copy link
Member

No, it doesn't work this way.
asyncio.gather() requires futures or coroutines, it means that Job should be derived from asyncio.Future.
But job and future have completely different API and serve different roles, let's keep everything as is.

@asvetlov asvetlov closed this Dec 17, 2024
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.

3 participants