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

asyncio interfaces #174

Open
aw-was-here opened this issue May 13, 2023 · 3 comments
Open

asyncio interfaces #174

aw-was-here opened this issue May 13, 2023 · 3 comments

Comments

@aw-was-here
Copy link
Contributor

aw-was-here commented May 13, 2023

Is your feature request related to a problem? Please describe.
tinytag is part of a larger app that needs to handle events as they arise. It would be useful if there was an asyncio interface to share CPU time.

Describe the solution you'd like
File reads for large files to use aiofiles or equivalent so that they aren't fully blocking reads.

Describe alternatives you've considered
Pushing the tinytag.get() call into an asyncio thread executor... which would work, but this feature feels like something that tinytag should support natively.

@mathiascode
Copy link
Collaborator

Would this change be enough? #178

@aw-was-here
Copy link
Contributor Author

Without an await somewhere, it is still holding the execution lock.

@mathiascode
Copy link
Collaborator

I assume you could do something like

async with aiofiles.open('filename', mode='rb') as f:
    contents = await f.read()
    tag = TinyTag.get(file_obj=BytesIO(contents))

If this isn't enough, suggestions on how to accomplish what you need without adding asyncio and aiofiles as dependencies to tinytag would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants