thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kumar, Ganesh" <kumar...@deshaw.com>
Subject Thrift Python Client fails to recover if arguments passed aren't of expected type
Date Tue, 18 Mar 2014 13:13:53 GMT
Hello,

If a service exposed through python client doesn't get the arguments of expected type (like
if it gets string in place of i32), the exception isn't handled cleanly, and the transport
needs to be closed & reopened for the client to be used again.

Suppose there is a service 'add' with its arguments of type i32, and the call has been with
type of argument as string. Since there is no check on type of arguments till the protocol
layer is reached, where struct.pack is called (for TBinaryProtocol )to serialize the value
on the underlying transport. Now at this point an exception is thrown which is propagated
upwards to the client caller. But the transport buffer isn't cleared (it seems there aren't
any API also to clear the buffer), when the next call is made through the same client, the
previous contents on buffer gets sent to the server, and an erroneous reply is received. Next
call onwards the connection gets stuck and client keeps on waiting.

Is there a way to solve this problem, or a workaround?

Thanks,
Ganesh


Example:

service Adder {
        i32 add(1: i32 a, 2: i32 b),
}

In [31]: client.add(11,2)
Out[31]: 13

In [32]: client.add(11, '2')
Error
.....
error: required argument is not an integer

In [33]: client.add(12, 2)
Out[33]: -2147418100


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message