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

Sultan.load() vs Sultan() #73

Open
metaperl opened this issue Nov 7, 2019 · 2 comments
Open

Sultan.load() vs Sultan() #73

metaperl opened this issue Nov 7, 2019 · 2 comments

Comments

@metaperl
Copy link

metaperl commented Nov 7, 2019

In Streaming Results from a Command we see:

with Sultan.load() as s:
    result = s.yum('install', '-y', 'postgresql').run(streaming=True)
    while True:
        # if full output is needed, read the pipes one last time
        # after `is_complete == True` to avoid a race condition
        complete = result.is_complete
        for line in result.stdout:
            print(line)
        for line in result.stderr:
            print(line)
        if complete:
            break
        time.sleep(1)

My question is: how different would this code be if Sultan.load() were replaced with Sultan().

@metaperl
Copy link
Author

metaperl commented Nov 7, 2019

is load documented anywhere? Is Sultan() documented anywhere?

@davydany
Copy link
Contributor

davydany commented Nov 9, 2019

Hey @metaperl ... the documentation for load() is here: https://sultan.readthedocs.io/en/latest/sultan-examples.html#example-2-sultan-with-context-management

All the examples there use the load() method.

If you were to use it with the constructor Sultan(), you can pass these contexts in with the context keyword argument, which is a dictionary. Sultan uses these determine the right type of bash command to generate based on the parameters you provide, so using load() is the right way to do it. I didn't document using Sultan() constructor because of this reason, since it is not the recommended way of doing so.

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

No branches or pull requests

2 participants