Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addget_opts andget_ranges#9

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
kylebarron wants to merge9 commits intoroeap:mainfromkylebarron:kyle/new-methods

Conversation

@kylebarron
Copy link
Contributor

  • The underlyingget_opts returns aGetResult. Soideally it would be nice to return a Python object that wraps thisGetResult so that in the future we could potentially stream a result into a Python AsyncIterator. However I don't think that would ever be possible because itsbytes andinto_stream consumeself. And you can't have a Python method that consumesself.

    So I think the best approach is to currently returnbytes and potentially in the future have a separateget_opts_stream method that returns an async iterator.

I had tried with

#[pyclass(name ="GetResult")]#[derive(Debug)]pubstructPyGetResult{rt:Arc<Runtime>,result:Arc<Mutex<GetResult>>,}#[pymethods]implPyGetResult{pubfnbytes(&self) ->PyResult<Cow<[u8]>>{let lock =self.rt.block_on(self.result.lock());let obj =self.rt.block_on(lock.bytes()).map_err(ObjectStoreError::from)?;Ok(Cow::Owned(obj.to_vec()))}pubfnbytes_async<'a>(&'aself,py:Python<'a>) ->PyResult<&PyAny>{        pyo3_asyncio::tokio::future_into_py(py,asyncmove{let obj =self.result.lock().await.bytes().await.map_err(ObjectStoreError::from)?;Ok(Cow::<[u8]>::Owned(obj.to_vec()))})}}

This is implemented on top of#6, and is expected to be reviewed after that.

rupurt and arogozhnikov reacted with heart emoji
@kylebarron
Copy link
ContributorAuthor

Closing because I implemented this inhttps://github.com/developmentseed/object-store-rs

@kylebarronkylebarron mentioned this pull requestOct 18, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@kylebarron

[8]ページ先頭

©2009-2025 Movatter.jp