[ 
https://issues.apache.org/jira/browse/THRIFT-616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12772652#action_12772652
 ] 

Julian Scheid commented on THRIFT-616:
--------------------------------------

Here you go.

{code}
Traceback (most recent call last):
  File 
"/redacted/build/python/all/redacted/thrift/protocol/RedactedService.py", line 
8979, in Foo
    self.send_Foo(arg1, arg2, arg3)
  File 
"/redacted/build/python/all/redacted/thrift/protocol/RedactedService.py", line 
8988, in send_Foo
    args.write(self._oprot)
  File 
"/redacted/build/python/all/redacted/thrift/protocol/RedactedService.py", line 
49636, in write
    oprot.writeString(self.arg1)
  File "/redacted/misc/thrift-py/thrift/protocol/TBinaryProtocol.py", line 123, 
in writeString
    self.trans.write(str)
  File "/redacted/misc/thrift-py/thrift/transport/TTransport.py", line 159, in 
write
    self.__wbuf.write(buf)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 
19: ordinal not in range(128)
{code}


> Transport should be reset on error
> ----------------------------------
>
>                 Key: THRIFT-616
>                 URL: https://issues.apache.org/jira/browse/THRIFT-616
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Python), Library (Python)
>            Reporter: Julian Scheid
>
> I'm running a recent snapshot and observed the following problem when sending 
> a message from Python: when an error is thrown after _oprot.writeMessageBegin 
> and before _oprot.trans.flush, the data that has already been written remains 
> in the transport's buffer. This seems to cause a deadlock in my case.
> The generated code currently looks like this:
> {code}
> self._oprot.writeMessageBegin(...)
> # snip
> args.write(self._oprot)
> self._oprot.writeMessageEnd()
> self._oprot.trans.flush()
> {code}
> Shouldn't it look like this?:
> {code}
> try:
>    self._oprot.writeMessageBegin(...)
>    # snip
>    self._oprot.writeMessageEnd()
>    self._oprot.trans.flush()
> except:
>    self._oprot.trans.reset()
>    raise
> {code}
> Where trans.reset() would clear the output buffer, for example in 
> TBufferedTransport do "self.__wbuf = StringIO()".
> Am I missing something?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to