You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Steve <st...@subwest.com> on 2012/06/14 20:43:07 UTC

Python - Killing an active Thrift call

Hi,

Is it possible to kill an active/open request in Python?

I have locking code around a thrift call, but sometimes the other side
(server) doesn't return (not in my control).  I would like to force that
connection to close so that the thread can continue on.

I've tried to close the transport, thinking it would fail out, but no luck.

Thanks.


Re: Python - Killing an active Thrift call

Posted by James Paton <jp...@gmail.com>.
I asked a question like this awhile ago on this list. I was told that Thrift does not have a way to interrupt an ongoing RPC from the client. In the past I have done this by interrupting the thread that was making the call (this was in Java), but this is probably not quite right as I imagine it leaves the server spinning.

-- Jim

On Jun 14, 2012, at 2:06 PM, Dan Kuebrich wrote:

> I don't know that there's a built-in facility for this, but it sounds like
> what timeouts are often used for.  How are you receiving the info that the
> other side won't return? Can you use timeouts on the thrift client sockets
> for this?
> 
> On Thu, Jun 14, 2012 at 2:43 PM, Steve <st...@subwest.com> wrote:
> 
>> Hi,
>> 
>> Is it possible to kill an active/open request in Python?
>> 
>> I have locking code around a thrift call, but sometimes the other side
>> (server) doesn't return (not in my control).  I would like to force that
>> connection to close so that the thread can continue on.
>> 
>> I've tried to close the transport, thinking it would fail out, but no luck.
>> 
>> Thanks.
>> 
>> 


Re: Python - Killing an active Thrift call

Posted by David Miller <da...@deadpansincerity.com>.
On 14 June 2012 20:06, Dan Kuebrich <da...@gmail.com> wrote:

> I don't know that there's a built-in facility for this, but it sounds like
> what timeouts are often used for.

Quite

>  Can you use timeouts on the thrift client sockets
> for this?


The Python TSocket class has a setTimeout method which IIUC is your best
bet for somewhere to bail on a call.

It raises some kind of exception IIRC (possibly socket.timeout, although
this would be trivial to check).

Example code here:

https://github.com/davidmiller/rpc/blob/master/rpc/thrifty.py#L13

-- 
Love regards etc

David Miller
http://www.deadpansincerity.com
07854 880 883

Re: Python - Killing an active Thrift call

Posted by Dan Kuebrich <da...@gmail.com>.
I don't know that there's a built-in facility for this, but it sounds like
what timeouts are often used for.  How are you receiving the info that the
other side won't return? Can you use timeouts on the thrift client sockets
for this?

On Thu, Jun 14, 2012 at 2:43 PM, Steve <st...@subwest.com> wrote:

> Hi,
>
> Is it possible to kill an active/open request in Python?
>
> I have locking code around a thrift call, but sometimes the other side
> (server) doesn't return (not in my control).  I would like to force that
> connection to close so that the thread can continue on.
>
> I've tried to close the transport, thinking it would fail out, but no luck.
>
> Thanks.
>
>