-
Notifications
You must be signed in to change notification settings - Fork 286
Fully Asyncio Support #308
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thriftpy/contrib/aio/protocol.py
Outdated
@@ -0,0 +1,441 @@ | |||
# -*- coding: utf-8 -*- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains too many copied code. At least some of them can be referenced instead of copied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wooparadog The asyncio support of #299 based on TFramedTransport
transport which is easier to be implemented. This transport tries to read the whole message out from socket at the begin and save it into buffer, it is easier because it just needs yield once from reading the whole message. My implementation based on another transport (TBinaryTransport
) so it may be a little bit verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's unavoidable for simpler abstraction, there should be a better code path like:
contrib/aio/binary_transport
contrib/aio/framed_transport
but it hurts so much for all those duplicate code...
@asyncio.coroutine | ||
def _send(self, _api, **kwargs): | ||
self._oprot.write_message_begin(_api, TMessageType.CALL, self._seqid) | ||
args = getattr(self._service, _api + "_args")() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thriftpy
simply ignored seqid
, but we better fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not a problem about asyncio support, maybe we can create another pull request to solve it both sync and async module.
Yeah I think it can be merged smoothly, I just resolved the last little conflict. |
@wooparadog The different between two pull requests is they realized different transport (I support bufferd and #299 supports memory bufferd). In my opinion, the buffered transport realization is more difficult than framed transport on this feature. And I also find that there are some blocking I/O at the low level not be yielded out in #299 realization ( |
@hit9 Could you merge this PR? |
I find #246 this issue so I wrote an asyncio support for thriftpy, and it can pass all the original test cases. Now you can use thriftpy like this: