Comments (10)
Generally, "Missing result" exception means you do not use the same thrift IDL in both server and client side, please check it. If you still got this exception, you can post a sample here, I will try to reproduce it.
from thriftpy2.
The code is very simple function for return a string, but the problem was i can't reproduce it , In my project , this exception happened very rare.
from thriftpy2.
I can not check or fix an irreproducible error.
from thriftpy2.
Sorry for that, Hope anyone else bear this problem can provide some suggest.
from thriftpy2.
@zyi1992 Can you tell us which client you are using? The client in thriftpy is quite low level, and doesn't handle many edge cases.
from thriftpy2.
from thriftpy.rpc import make_client
client = make_client(service, host, port, timeout=timeout)
This was the client define code.
from thriftpy2.
@zyi1992 , @ethe has came up with a possible explanation yesterday. The problem is that make_client in thriftpy doesn't handle timeout by itself, so weird things might happen if a timeout occurs.
Background: The client produced by make_client is basically based on a single connection, and won't handle any exceptions during communication(according to the original python-thrift).
What happens:
- First rpc call made to server
- Server hangs for more than timeout set by client.
- Client raise socket.timeout error. but the connection is still open
- Server finishes the first rpc response and send it to client. Data will be stored in client's buffer.
- Client makes a second request, and try to get its response.
- Client reads from buffer which contains response for the first one.
- Raise weird protocol exceptions(including missing result)
The fix is to do proper connection management, you can write it according to your scenarios. We are using thrift_connector
in that matter.
from thriftpy2.
Thanks for you reply, I will have a try on thrift_connector. It seems like thrift_connector didn't deal with thriftpy server restart exception, When use thriftpy with gunicron_thrift, the server side restart will cause client side to raise a TTransportException excetion, is there a best practice for auto reconnection without restart exception.
from thriftpy2.
@zyi1992 Actually, thrift_connector does handle this situation by preventing it rather than raising a TTransportException.
Before every rpc, thrift_connector will try to validate the connection by calling ping
thrift method, then the actual rpc. If any error occurs during ping, it'll simply create a new connection for this rpc.
Code: https://github.com/Thriftpy/thrift_connector/blob/master/thrift_connector/connection_pool.py#L82
There are many practices out there:
- Validating connection before every call. (Default in thrift_connector. In our server implementation, server will raise a ServerShutdownException in
ping
if server is gracefully shutting down.) - Maintaining a thread to make sure all connections in connection pool are valid. (Also implemented in thrift_connector, but for performance issues, we don't use it)
- Use event polling to discover closed connections and process them.
The best method is 3
, but we havn't got time to dig deeper than doing a POC.
from thriftpy2.
Thanks for you explain.
from thriftpy2.
Related Issues (20)
- Investigate build issue involving cython and thriftpy in container build HOT 7
- Cannot pip install thriftpy2 on Colab HOT 9
- Cython issue still occurring because the fix wasn't published HOT 4
- import hook does not work with Python3.12 HOT 1
- can not pip install on python 3.7 HOT 1
- Thrift IDL file parse reports error in multi-threaded situation
- Remove Python2 support
- Asyncio client creates RuntimeError on parallel requests HOT 7
- Build fails with strict-aliasing violations HOT 3
- Deprecated tornado server and client
- Get rid of using fork start method for `mp` module in the tests
- AttributeError: '_thread._local' obiect has no attribute 'thrift_stack' HOT 3
- [BUG] Asynchronous Client Hangs When Connecting to Non-Existent IP
- How to solve '_thread._local' object has no attribute 'thrift_stack' HOT 2
- how to get the annotation of service function? HOT 4
- thriftpy2.load fail HOT 6
- Calling `parse_fp()` in v0.5.1 results in "AttributeError: '_thread._local' object has no attribute 'thrift_cache'" HOT 5
- Move more static matadata from setup.py/setup.cfg to project.toml
- `thriftpy2.load_fp` can't load a thrift file with a include statement
- Add `thriftpy2.load_str`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thriftpy2.