Skip to content

Commit

Permalink
Added support for Pure Python Functions (apache#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
srkukarni authored and sijie committed Mar 4, 2018
1 parent 37a0b63 commit a025bfe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
#
# 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.
#

def process(self, input, context):
return input + '!'
5 changes: 4 additions & 1 deletion pulsar-functions/runtime/src/main/python/python_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ def run(self):
)

function_kclass = util.import_class(os.path.dirname(self.user_code), self.instance_config.function_config.className, try_internal=True)
self.function_class = function_kclass()
try:
self.function_class = function_kclass()
except:
self.function_class = function_kclass

self.contextimpl = contextimpl.ContextImpl(self.instance_config, Log, self.pulsar_client, self.user_code, self.consumers)
# Now launch a thread that does execution
Expand Down

0 comments on commit a025bfe

Please sign in to comment.