-
Notifications
You must be signed in to change notification settings - Fork 181
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
Plumbum should have asyncio support #530
Comments
@henryiii - What do you think? |
I've thought about this before, but haven't had the time or enough familiarity with async (seems like I never get past making simple examples and demos, it hasn't quite been enough for ). Ideally, I assume this would be useful either as a base or a guide: https://docs.python.org/3/library/asyncio-subprocess.html. I have a few long term plans (but not enough time to do them): I'd like to break off at least |
If I'm reading this right you are considering the async support replacing the sync support, for a 2.0 after the 1.7 stuff is done? |
It would be in addition to it, not a replacement - in fact, it seems possible to detect if something is being called in await, so it might be possible to be pretty elegant in allowing both. I was referring more to the fact we could possibly keep the backends from diverging too badly by updating the sync backend to look like the async backend (assuming we can use the higher level abstractions now). |
If you want to draft a basic proposal and/or proof of concept PR, I'd be happy to review and discuss. |
Skimming the code so far, it looks like some of the issues with implementing this is going to be almost a rewrite. For example, we should ideally allow Do you have any suggestions on what the base areas of code would be that I should work on updating or changing here? |
So my basic proposal would be for async support to have init without side affects as part of the design. This would be a breaking change even for sync users... Though we can move the side affects to many common uses, e.g. contextmanager could do the connection init does. I would likely want to help with the earlier refactoring bits ahead of async, such as the plumbum.colorlib and plumbum.cli stuff you mentioned. Would you like that in its own repo or side by side in this repo? |
How about we develop them in |
@henryiii so I think before getting too deep on the new async support, it would benefit me to have some guidance on what API designs you consider essential/must have. Where you consider the async boundaries should be, and how we can implement it to cope. For example I think a lot of plumbums use of That said, I have started on a bit of a mockup, barely into it pending a chance to discuss the above with you, or find a good sync place/time to chat. So far this is lacking a bunch:
|
Most important for starting out is the API. What will it look like in use? Most of I'll try to push 1.7.0 soon. |
Personally, I like writing a bit of docs-like (or sometimes tests-like) material first, something like this: from plumbum import cmd
async with cmd.ls:
pass I'd start with what would be absolutely ideal, and then it can be made a bit more practical as the implementation comes together. For example, in the above expression, maybe it turns out that we need an explicit method to return the async context manager for foreground/background, so we'd eventually need I'd pick a couple of simi-real world examples, one local and one remote. Feel free to write nicer test files for new tests, we don't have to keep the old class structure; that was due to a conversion from unittest style testing. Simpler tests + fixtures are much nicer. :) |
FYI, Python 2 has been removed, and I'm working on cleaning up the code a bit. Static types are starting to show up, etc. :) |
I feel that being able to use await/etc syntax with plumbum would be helpful in a lot of areas, especially for remote machine use. I may be able to work on implementing this in my work time but would love insight on if this would be accepted by the maintainer and any thoughts on how this should be implemented.
The text was updated successfully, but these errors were encountered: