Skip to content

THRIFT-4548: python binary accelerated protocol with multiplexing via decoration#1547

Merged
jeking3 merged 4 commits intoapache:masterfrom
nijm:thrift_4548_binary_accel_multiplexed
Jun 8, 2018
Merged

THRIFT-4548: python binary accelerated protocol with multiplexing via decoration#1547
jeking3 merged 4 commits intoapache:masterfrom
nijm:thrift_4548_binary_accel_multiplexed

Conversation

@nijm
Copy link
Contributor

@nijm nijm commented Apr 17, 2018

THRIFT-4548: multiplexed (decorated) protocols inherit from TProtocolBase
Client: py

TMultiplexedProtocol objects did not inherit from TProtocolBase, so the decorated protocol object passed into the binary accelerated C extension was not really a TProtocolBase object, which caused errors. This implementation decorates the protocol object by dynamically creating a new class that extends both the class of the protocol being decorated and TMultiplexedProtocol.

I tested the changes locally. I had trouble running the full suite of cross tests, but running the py,py3 cross tests worked, although I'm not sure these are testing multiplexed protocols.

@jeking3
Copy link
Contributor

jeking3 commented Apr 18, 2018

Very nice - I knew something was wrong when I had to disable that many tests as I added multiplexed support to TestClient, so I'm really glad to see you figured it out and removed the test exclusions!

Test failures: Appveyor: Looks like oracle moved a download link and the chocolatey package hasn't been updated yet. Not relevant to this change.

sca build failure:

# Python code style
flake8 --ignore=E501 --exclude=lib/py/build lib/py
lib/py/src/protocol/TProtocolDecorator.py:23:41: E226 missing whitespace around arithmetic operator
lib/py/src/protocol/TProtocolDecorator.py:27:1: W391 blank line at end of file

Recommend you run the flake8 commands in build/docker/scripts/sca.sh after making python code changes to avoid that in the future. We might even want to teach our regular make to do this if it's fast.

ubsan failure is an intermittent lisp compiler issue where it cannot find a temporary file it just wrote - not relevant here.

Cross test failure is real and related to the changes:

*************************** client message ***************************
Tue Apr 17 17:11:46 2018
Executing: /thrift/src/test/py/TestClient.py --verbose --host=localhost --genpydir=gen-py --protocol=multi --transport=framed --port=46135
Directory: /thrift/src/test/py
config:delay: 5
config:timeout: 10
===============================================================================
EEEEEEEEEEEEEEEEEEEEEE
======================================================================
ERROR: testBinary (__main__.MultiplexedBinaryTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/thrift/src/test/py/TestClient.py", line 148, in testBinary
    self.assertEqual(bytearray(self.client.testBinary(bytes(val))), val)
  File "/thrift/src/test/py/gen-py/ThriftTest/ThriftTest.py", line 574, in testBinary
    self.send_testBinary(thing)
  File "/thrift/src/test/py/gen-py/ThriftTest/ThriftTest.py", line 578, in send_testBinary
    self._oprot.writeMessageBegin('testBinary', TMessageType.CALL, self._seqid)
  File "/thrift/src/lib/py/build/lib.linux-x86_64-2.7/thrift/protocol/TMultiplexedProtocol.py", line 33, in writeMessageBegin
    super().writeMessageBegin(
TypeError: super() takes at least 1 argument (0 given)

if (type == TMessageType.CALL or
type == TMessageType.ONEWAY):
self.protocol.writeMessageBegin(
super().writeMessageBegin(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super() takes at least 1 argument

)
else:
self.protocol.writeMessageBegin(name, type, seqid)
super().writeMessageBegin(name, type, seqid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super() takes at least 1 argument

@nijm
Copy link
Contributor Author

nijm commented Apr 18, 2018

I've cleared most of the cross-test failures. It looks like the remaining failures are SSL-related timeouts (if I've interpreted the logs correctly). I don't think they're related to this change, but please let me know if they are.

Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could rebase on master and push, it'll kick a new appveyor build for us. When this was submitted, chocolatey was down or something related to jdk8 was unavailable.

nijm added 3 commits May 1, 2018 15:57
TMultiplexedProtocol objects did not inherit from TProtocol, so the
decorated protocol object passed into the binary accelerated C extension
was not really a TProtocol object, which caused errors. This
implementation decorates the protocol object by dynamically creating a
new class that extends both the class of the protocol being decorated
and TMultiplexedProtocol.
@nijm nijm force-pushed the thrift_4548_binary_accel_multiplexed branch from 7976d7e to f6bf42a Compare May 1, 2018 14:58
@nijm
Copy link
Contributor Author

nijm commented May 2, 2018

That's done. The travis build still has the same SSL timeouts, but the AppVeyor build succeeded (even though it looks like there was a problem with javadoc).

@jeking3 jeking3 self-assigned this May 14, 2018
Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following failures are related:

cpp-py                  multic            http-ip                  failure(timeout)
cpp-py                  multic            http-ip-ssl              failure(timeout)
cpp-py                  multic-multiac    http-ip                  failure(timeout)
cpp-py                  multic-multiac    http-ip-ssl              failure(timeout)
cpp-py                  multij            http-ip                  failure(timeout)
cpp-py                  multij            http-ip-ssl              failure(timeout)
cpp-py                  multi             http-ip                  failure(timeout)
cpp-py                  multi             http-ip-ssl              failure(timeout)
cpp-py                  multi-multia      http-ip                  failure(timeout)
cpp-py                  multi-multia      http-ip-ssl              failure(timeout)
cpp-py3                 multic            http-ip                  failure(timeout)
cpp-py3                 multic            http-ip-ssl              failure(timeout)
cpp-py3                 multic-multiac    http-ip                  failure(timeout)
cpp-py3                 multic-multiac    http-ip-ssl              failure(timeout)
cpp-py3                 multij            http-ip                  failure(timeout)
cpp-py3                 multij            http-ip-ssl              failure(timeout)
cpp-py3                 multi             http-ip                  failure(timeout)
cpp-py3                 multi             http-ip-ssl              failure(timeout)
cpp-py3                 multi-multia      http-ip                  failure(timeout)
cpp-py3                 multi-multia      http-ip-ssl              failure(timeout)

You can leave the http based cpp server tests disabled. cpp has known issues with http documented in THRIFT-3877 on Jira.

@cosven
Copy link

cosven commented May 24, 2018

so the decorated protocol object passed into the binary accelerated C extension was not really a TProtocolBase object, which caused errors.

As far as I know, the C extension does not care what protocol type Python passed into. It just uses the BinaryProtocol or CompatProtocol define in bianry/compat.h to do encoding and decoding.

In my opinion, the real problem is that TXxxProtocol()._fast_encode is BuiltInFunction instead of a Method(at the moment). And the TProtocolDecorator._wrap does not handle this case.

@nijm
Copy link
Contributor Author

nijm commented Jun 4, 2018

I have disabled the http based cpp server tests - the remaining cross language tests are all passing.

@jeking3 jeking3 merged commit 747158c into apache:master Jun 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants