thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4548) Supporting TBinaryProtocolAccelerated protocol when using TMultiplexedProcessor in Python
Date Fri, 08 Jun 2018 00:31:00 GMT

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

ASF GitHub Bot commented on THRIFT-4548:
----------------------------------------

jeking3 closed pull request #1535: THRIFT-4548: Supporting TBinaryProtocolAccelerated protocol
when using TMultiplexedProcessor in Python
URL: https://github.com/apache/thrift/pull/1535
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/lib/py/src/TMultiplexedProcessor.py b/lib/py/src/TMultiplexedProcessor.py
index 605aa1f252..28a3aa92e8 100644
--- a/lib/py/src/TMultiplexedProcessor.py
+++ b/lib/py/src/TMultiplexedProcessor.py
@@ -18,7 +18,7 @@
 #
 
 from thrift.Thrift import TProcessor, TMessageType, TException
-from thrift.protocol import TProtocolDecorator, TMultiplexedProtocol
+from thrift.protocol import TMultiplexedProtocol
 
 
 class TMultiplexedProcessor(TProcessor):
@@ -43,13 +43,5 @@ def process(self, iprot, oprot):
             raise TException("Service name not found: " + serviceName + ". Did you forget
to call registerProcessor()?")
 
         standardMessage = (call, type, seqid)
-        return self.services[serviceName].process(StoredMessageProtocol(iprot, standardMessage),
oprot)
-
-
-class StoredMessageProtocol(TProtocolDecorator.TProtocolDecorator):
-    def __init__(self, protocol, messageBegin):
-        TProtocolDecorator.TProtocolDecorator.__init__(self, protocol)
-        self.messageBegin = messageBegin
-
-    def readMessageBegin(self):
-        return self.messageBegin
+        iprot.readMessageBegin = lambda: standardMessage
+        return self.services[serviceName].process(iprot, oprot)
diff --git a/lib/py/src/protocol/TMultiplexedBinaryProtocolAccelerated.py b/lib/py/src/protocol/TMultiplexedBinaryProtocolAccelerated.py
new file mode 100644
index 0000000000..a0864f88dc
--- /dev/null
+++ b/lib/py/src/protocol/TMultiplexedBinaryProtocolAccelerated.py
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from thrift.Thrift import TMessageType
+from thrift.protocol.TBinaryProtocol import TBinaryProtocolAccelerated
+
+class TMultiplexedBinaryProtocolAccelerated(TBinaryProtocolAccelerated):
+    def __init__(self, serviceName, *args, **kwargs):
+        super(TMultiplexedBinaryProtocolAccelerated, self).__init__(*args, **kwargs)
+        self.serviceName = serviceName
+        self.separator = ":"
+
+    def writeMessageBegin(self, name, type, seqid):
+        if (type == TMessageType.CALL or type == TMessageType.ONEWAY):
+            super(TMultiplexedBinaryProtocolAccelerated, self).writeMessageBegin(self.serviceName
+ self.separator + name, type, seqid)
+        else:
+            super(TMultiplexedBinaryProtocolAccelerated, self).writeMessageBegin(name, type,
seqid)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Supporting TBinaryProtocolAccelerated protocol when using TMultiplexedProcessor in Python
> -----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-4548
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4548
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Balazs Kemenes
>            Priority: Major
>
> Supporting TBinaryProtocolAccelerated protocol when using TMultiplexedProcessor in Python



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message