Skip to content
This repository has been archived by the owner on Jun 25, 2018. It is now read-only.

Better documentation for rust-python interop #82

Open
spease opened this issue Dec 3, 2017 · 4 comments
Open

Better documentation for rust-python interop #82

spease opened this issue Dec 3, 2017 · 4 comments

Comments

@spease
Copy link

spease commented Dec 3, 2017

Hey, this is great. It's exactly what I need for a project I'm working on. Is there any documentation or examples on how to use it in a project using Rust code with tokio that calls python with asyncjo/aiohttp? Thanks much.

@fafhrd91
Copy link
Collaborator

fafhrd91 commented Dec 3, 2017

why do you need aiohttp, why can't you use hyper on rust side?

@spease
Copy link
Author

spease commented Dec 3, 2017

Porting an existing codebase that's doing http calls itself with aiohttp client

@fafhrd91
Copy link
Collaborator

fafhrd91 commented Dec 3, 2017

ok.
there is no example, but here how you can do this

  1. import aiohttp (example https://github.com/PyO3/tokio/blob/master/src/utils.rs#L53)
  2. call aiohttp (example how to call https://github.com/PyO3/tokio/blob/master/src/utils.rs#L193)
  3. downcast result into PyFuture. PyFuture implements Future trait and you can wait for result in rust
    this future resolves into PyObject, it is ClientResponse object.

@fafhrd91
Copy link
Collaborator

fafhrd91 commented Dec 3, 2017

it is not very pleasant experience :)

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

No branches or pull requests

2 participants