You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by smallfish <gi...@git.apache.org> on 2014/03/04 17:40:24 UTC

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

GitHub user smallfish opened a pull request:

    https://github.com/apache/thrift/pull/82

    THRIFT-1914 Python: Support for Multiplexing Services on any Transport

    copy patch from: https://issues.apache.org/jira/browse/THRIFT-1914 add some testcases.
    
    add new options `multiple`, if set `True`, will test  `ThriftTest` and `SecondService`.
    
    run server:
    
        $ python TestServer.py --port=9999 --multiple -v TSimpleServer
    
    run client:
    
        $ python TestClient.py --host=127.0.0.1 --port=9999 --multiple
        ...................
        ----------------------------------------------------------------------
        Ran 19 tests in 0.693s
    
        OK

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/smallfish/thrift master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/thrift/pull/82.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #82
    
----
commit 4b5e276a43371b5d5cccbf9ca9fbcea790ae6881
Author: smallfish <sm...@gmail.com>
Date:   2014-03-04T16:34:59Z

    THRIFT-1914 Python: Support for Multiplexing Services on any Transport, Protocol and Server, add testcases

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by haijunz <gi...@git.apache.org>.
Github user haijunz commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/82#discussion_r12255168
  
    --- Diff: lib/py/src/TMultiplexedProcessor.py ---
    @@ -0,0 +1,58 @@
    +#
    +# 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 TProcessor, TMessageType, TException
    +from thrift.protocol import TProtocolDecorator, TMultiplexedProtocol
    +
    +class TMultiplexedProcessor(TProcessor):
    +  def __init__(self):
    +    self.services = {}
    +
    +  def registerProcessor(self, serviceName, processor):
    +    self.services[serviceName] = processor
    +
    +  def process(self, iprot, oprot):
    +    (name, type, seqid) = iprot.readMessageBegin();
    +    if type != TMessageType.CALL & type != TMessageType.ONEWAY:
    +      raise TException("This should not have happened!?")
    +
    +    index = name.find(TMultiplexedProtocol.SEPARATOR)
    +    if index < 0:
    +      raise TException("Service name not found in message name: " + name + ". Did you forget to use TMultiplexProtocol in your client?")
    +
    +    serviceName = name[0:index]
    +    call = name[index+len(TMultiplexedProtocol.SEPARATOR):]
    +    if not self.services.has_key(serviceName):
    --- End diff --
    
    Can you use in instead:
    if not serviceName in self.services:


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by bufferoverflow <gi...@git.apache.org>.
Github user bufferoverflow commented on the pull request:

    https://github.com/apache/thrift/pull/82#issuecomment-42109884
  
    please close this issue. its's committed via #103 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by djwatson <gi...@git.apache.org>.
Github user djwatson commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/82#discussion_r12213289
  
    --- Diff: lib/py/src/TMultiplexedProcessor.py ---
    @@ -0,0 +1,58 @@
    +#
    +# 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 TProcessor, TMessageType, TException
    +from thrift.protocol import TProtocolDecorator, TMultiplexedProtocol
    +
    +class TMultiplexedProcessor(TProcessor):
    +  def __init__(self):
    +    self.services = {}
    +
    +  def registerProcessor(self, serviceName, processor):
    +    self.services[serviceName] = processor
    +
    +  def process(self, iprot, oprot):
    +    (name, type, seqid) = iprot.readMessageBegin();
    +    if type != TMessageType.CALL & type != TMessageType.ONEWAY:
    +      raise TException("This should not have happened!?")
    --- End diff --
    
    Can we get a better error message?  "TMultiplex protocol only supports CALL & Oneway" or something


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by smallfish <gi...@git.apache.org>.
Github user smallfish commented on the pull request:

    https://github.com/apache/thrift/pull/82#issuecomment-41000854
  
    @bufferoverflow 
    Sorry, submitted with the wrong user/email several commits. 
    I create new pull request: #103, it's clean.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by bufferoverflow <gi...@git.apache.org>.
Github user bufferoverflow commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/82#discussion_r11825463
  
    --- Diff: test/py/TestServer.py ---
    @@ -201,7 +217,7 @@ def testMulti(self, arg0, arg1, arg2, arg3, arg4, arg5):
     host = None
     if options.ssl:
       from thrift.transport import TSSLSocket
    -  transport = TSSLSocket.TSSLServerSocket(host, options.port, certfile='../keys/server.pem')
    +  transport = TSSLSocket.TSSLServerSocket(host, options.port, certfile='test_cert.pem')
    --- End diff --
    
    could you please keep ../keys/server.pem here? test_cert.pem is not available anymore


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by jfarrell <gi...@git.apache.org>.
Github user jfarrell closed the pull request at:

    https://github.com/apache/thrift/pull/82


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by haijunz <gi...@git.apache.org>.
Github user haijunz commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/82#discussion_r12252798
  
    --- Diff: lib/py/src/protocol/TProtocolDecorator.py ---
    @@ -0,0 +1,42 @@
    +#
    +# 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.protocol.TProtocol import TProtocolBase
    +from types import *
    +
    +class TProtocolDecorator():
    +  def __init__(self, protocol):
    +    TProtocolBase(protocol)
    +    self.protocol = protocol
    +
    +  def __getattr__(self, name):
    +    if hasattr(self.protocol, name):
    +      member = getattr(self.protocol, name)
    +      if type(member) in [MethodType, UnboundMethodType, FunctionType, LambdaType, BuiltinFunctionType, BuiltinMethodType]:
    --- End diff --
    
    Is UnboundMethodType still needed? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] thrift pull request: THRIFT-1914 Python: Support for Multiplexing ...

Posted by Jens-G <gi...@git.apache.org>.
Github user Jens-G commented on the pull request:

    https://github.com/apache/thrift/pull/82#issuecomment-41959894
  
    So this one is obsolete?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---