-
Notifications
You must be signed in to change notification settings - Fork 192
asyncio backend #10
Comments
That's definitely the way to go. |
asyncio will be rough. As I understand it (from a recent post to python-dev) the docs are barely there. This would be an awesome feature though. |
Yeah, I acknowledge that the lack of docs are a problem. I'm not going to really attack this until 3.4 happens, but I'm pretty hopeful that I can make this work. |
Based on this article here, all we need to do is to have our synchronous wrapper APIs call this: loop = asyncio.get_event_loop()
loop.run_until_complete(print_page('http://example.com')) |
Having concluded that we can definitely do this, it's time to do some API design. What's a good asynchronous API going to look like? First, let's all acknowledge that the >>> conn = HTTP20Connection('twitter.com:443')
>>> resp = yield from conn.request('POST', '/some/path', headers=headers, body=body) The incremental 'build it as you go' API is one that I'm open to keeping, especially as it's very useful for sending data in chunks, but it's not really well designed for HTTP/2.0 at the moment. My best idea ATM is to refactor it into three methods: >>> conn = HTTP20Connection('twitter:443')
>>> stream_id = yield from conn.send_headers(headers)
>>> for chunk in some_slow_generator():
>>> yield from conn.send_data(chunk)
>>> resp = yield from conn.get_response() It'd be useful to get input from people who might actually end up interacting with this interface: how'd you like it to look? /cc @sigmavirus24, @shazow, @piotr-dobrogost. /cc @kennethreitz if he finds time, as his input would be hugely valuable. |
Hmm, I've got a large quantity of the |
Ok, I've fixed that up (hopefully) and gotten to the stage where I can start running some tests. This doesn't actually work because the tests all use the old synchronous API and I haven't implemented a wrapper for it yet. That's the next work item. |
It's possible that there are interesting developments in Python that might affect my approach to this. Watch this space. |
watching intensifies |
So, PEP 466 is what I was referring to. If this gets accepted then it opens the door for Python 2.7 to have an |
We've added support for Python 2.7, which makes this a no-go. |
It would be awesome if we could have an
asyncio
-based backend that exposes an optional synchronous API. I have no idea if we can do this or not but I'd love it if we could, it would clean the code up tremendously.The text was updated successfully, but these errors were encountered: