ryanwang520 / aiothrift Goto Github PK
View Code? Open in Web Editor NEWAsyncIO (PEP 3156) Thrift support
License: MIT License
AsyncIO (PEP 3156) Thrift support
License: MIT License
Hi,
create_server does not pass kw to asyncio.start_server at v0.1, so it's hardly support SSL.
BUT,
The latest aiothrift/server.py has already add kw.
I am expecting a release.
Python 3.7.3 / aiothrift 0.2.3 / thrifypy2 0.4.14
Aiothrift create_pool is not respecting my timeout param,
rpc_to_worker = await aiothrift.create_pool(
service=service,
address=(ip, 6985),
timeout=2)
It takes around a minute to timeout.
This line is in aiothrift connection.py,
reader, writer = await asyncio.open_connection(host, port, **kw)
Timeout behaviour seems to work when the above line is changed to this,
fut = asyncio.open_connection(host, port, **kw)
reader, writer = await asyncio.wait_for(fut, timeout=timeout)
Adapted from here, https://stackoverflow.com/questions/29756507/how-can-i-add-a-connection-timeout-with-asyncio.
map<i32,i32> test(1: list<i32> ids)
, would cause error RuntimeWarning: coroutine 'read_map_begin' was never awaited
await
for k_type, v_type, sz = read_map_begin(reader)
A mistake I make every now and then is to either (1) supply the incorrect Service identifier to a create_pool command or (2) supply the incorrect Service identifier when I instantiate a thrift server. The resulting error messages do not give much insight into the cause of the problem.
Over time I have written a long checklist of possible causes of problems that I can work through to find the cause of the error. Still, someone in this position would suffer less loss-of-momentum if the error messages were more descriptive. This ticket is a request to improve error handling.
In a situation just now, I incorrectly instantiated the thrift server, by supplying the wrong Service as an argument to aiothrift.create_server. For this situation, the stack trace given on the client side is helpful, because it allows me to see which call is not being dealt with correctly.
The logging on the incorrectly setup-up server side is unhelpful,
{path}/venv/lib/python3.7/site-packages/aiothrift/protocol.py:466: RuntimeWarning: coroutine 'skip' was never awaited
skip(self.trans, ttype)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "{path}{/venv/lib/python3.7/site-packages/aiothrift/server.py", line 31, in __call__
await self.processor.process(iproto, oproto)
File "{path}/venv/lib/python3.7/site-packages/aiothrift/processor.py", line 68, in process
api, seqid, result, call = await self.process_in(iprot)
File "{path}/venv/lib/python3.7/site-packages/aiothrift/processor.py", line 16, in process_in
await iprot.skip(TType.STRUCT)
TypeError: object NoneType can't be used in 'await' expression
Could the client side check for a None situation, and give an error message instead of this stack trace above? As an example of the error message, "There is no exposed method {blah} on service interface {name of incorrectly instantiated Service}"?
I am using 0.2.5, installed via pip.
Logging shows this error, from TBinaryProtocol::skip,
/home/admin/pydist/lib/aiothrift/protocol.py:466: RuntimeWarning: coroutine 'skip' was never awaited
skip(self.trans, ttype)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I am trying to get a thriftpy server to use aiothrift without changing the clients. When I send a request to the server I am getting the following exception:
2017-12-05 17:36:59,860 aiothrift[53]: CRITICAL unhandled app exception
Traceback (most recent call last):
File "/home/thesamet/dev/tbcode/.pants.d/pyprep/requirements/CPython-3.5.3/3df7c8a19a9b0f11a6528cd277dcbb5b2e6c3adb/.deps/aiothrift-0.1-py3-none-any.whl/aiothrift/server.py", line 23, in __call__
yield from self.processor.process(iproto, oproto)
File "/home/thesamet/dev/tbcode/.pants.d/pyprep/requirements/CPython-3.5.3/3df7c8a19a9b0f11a6528cd277dcbb5b2e6c3adb/.deps/aiothrift-0.1-py3-none-any.whl/aiothrift/processor.py", line 71, in process
api, seqid, result, call = yield from self.process_in(iprot)
File "/home/thesamet/dev/tbcode/.pants.d/pyprep/requirements/CPython-3.5.3/3df7c8a19a9b0f11a6528cd277dcbb5b2e6c3adb/.deps/aiothrift-0.1-py3-none-any.whl/aiothrift/processor.py", line 18, in process_in
api, type, seqid = yield from iprot.read_message_begin()
File "/home/thesamet/dev/tbcode/.pants.d/pyprep/requirements/CPython-3.5.3/3df7c8a19a9b0f11a6528cd277dcbb5b2e6c3adb/.deps/aiothrift-0.1-py3-none-any.whl/aiothrift/protocol.py", line 425, in read_message_begin
self.trans, strict=self.strict_read)
File "/home/thesamet/dev/tbcode/.pants.d/pyprep/requirements/CPython-3.5.3/3df7c8a19a9b0f11a6528cd277dcbb5b2e6c3adb/.deps/aiothrift-0.1-py3-none-any.whl/aiothrift/protocol.py", line 176, in read_message_begin
message='No protocol version header')
thriftpy.protocol.exc.TProtocolException: TProtocolException(type=4)
I see that the expectation of getting a version can be controlled by a variable named strict_read
, but I don't see a way to control it as a user through create_server()
.
I am not too familiar with the thrift wire format - is my client code being non-conforming if it doesn't send version information?
seems not working with TNonblockingServer, whose communication always be with header of 4bytes message length
Are there any plans to support UDP communications?
I came across this library while trying to create a asyncio compatible client for the Jaeger OpenTracing collector. The collector accepts Thrift binary format trace information by listening on a datagram interface. The existing Python jaeger client is a Python 2.7 library which is not suitable for use in my Python 3 asyncio based applications.
Would the change roughly be adding a create_datagram_endpoint
function (similar to the existing open_connection
) and then creating something like a ThriftDatagram that takes a asyncio.DatagramProtocol
in a similar way to the existing ThriftConnection
?
If the server raises an exception then those exceptions aren't propagated to the client. The normal thrift library automatically handles this by sending a ThriftApplicationException from the server to the client as part of the response message.
How can I propagate exceptions from the server to the client using aiothrift? Any help would be appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.