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

add support for Process Credentials Provider #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ojii
Copy link
Contributor

@ojii ojii commented Oct 15, 2024

Adds support for Process Credentials Provider

Comment on lines +590 to +594
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
stdin=asyncio.subprocess.PIPE,
)
stdout, stderr = await process.communicate(b"")
Copy link
Contributor

Choose a reason for hiding this comment

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

This would block if the subprocess produces too much data.

Arguably there should be a default timeout too, although, perhaps in this particular library, the caller has a timeout and will cancel fetch_metadata.

A simple fix could look smth like:

try:
    stdout, stderr = await asyncio.wait_for(
        process.communicate(b""), timeout=30
    )
except asyncio.TimeoutError:
    process.kill()
    await process.wait()
    raise ProcessCredentialsError("Subprocess timed out", None, b"", b"")

I dunno if it's worth it in practice.

)
try:
data = json.loads(stdout)
except json.JSONDecodeError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm I can't recall if they fixed this or not. Back in the day, except ValueError was better, because JSONDecodeError inherits from it, and in some special cases loads could raise a plain ValueError?

def try_decode(data: bytes) -> str:
try:
return data.decode()
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
except:
except Exception:

unless the intention is to swallow e.g. SystemExit if it happens at just the right time.

Copy link
Contributor

@dimaqq dimaqq left a comment

Choose a reason for hiding this comment

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

It would be great to add some super-simple snippet about how to use this in real life.

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