Skip to content

Commit

Permalink
[STREAMPIPES-174] switch to waitress for serving, fixed some minors
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Wiener committed Aug 17, 2020
1 parent 4a16d18 commit 4c07b97
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion streampipes-wrapper-python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bjoern==3.1.0
waitress==-1.4.4
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
Expand Down
2 changes: 1 addition & 1 deletion streampipes-wrapper-python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'Flask==1.1.2',
'flask-classful==0.14.2',
'Flask-Negotiate==0.1.0',
'bjoern==3.1.0',
'waitress==1.4.4',
'python-consul==1.1.0'
],
tests_require=[],
Expand Down
3 changes: 2 additions & 1 deletion streampipes-wrapper-python/streampipes/api/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
import abc
import os
from flask import jsonify, make_response
from flask import jsonify, make_response, request
from flask_classful import FlaskView, route
from flask_negotiate import consumes

Expand Down Expand Up @@ -85,6 +85,7 @@ class InvocableElement(Element):
def invoke_runtime(self, element_id: str):
# TODO: parse invocation graph
# payload = request.json
print(request.json)
resp = {'element_id': element_id, 'status': 'sucess'}
return make_response(jsonify(resp), 200)

Expand Down
6 changes: 3 additions & 3 deletions streampipes-wrapper-python/streampipes/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
""" API endpoints """
import threading

import bjoern
from waitress import serve
from flask import Flask

from streampipes.api.resources.dummy import DummyInterimsResource
Expand All @@ -44,6 +44,6 @@ def __init__(self):
DummyInterimsResource.register(self.app, route_base='/')

def run(self, port: int):
print('serving API via bjoern WSGI server ... http://{}:{}'.format('0.0.0.0', port))
threading.Thread(target=bjoern.run, args=(self.app,), kwargs={'host': '0.0.0.0', 'port': int(port)}).start()
print('serving API via waitress WSGI server ... http://{}:{}'.format('0.0.0.0', port))
threading.Thread(target=serve, args=(self.app,), kwargs={'host': '0.0.0.0', 'port': int(port), '_quiet': True}).start()

2 changes: 1 addition & 1 deletion streampipes-wrapper-python/streampipes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class EventProcessor(object):
__metaclass__ = abc.ABC0
__metaclass__ = abc.ABC

_DEFAULT_KAFKA_CONSUMER_CONFIG = {
'bootstrap.servers': 'kafka:9092',
Expand Down
10 changes: 5 additions & 5 deletions streampipes-wrapper-python/streampipes/declarer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def get_processor(cls, key):
def get(cls):
return cls._processors

# def get_declarers(self):
# return self.sepa_declarers
#
# def get_base_uri(self):
# return 'http://' + self.host + ':' + self.port + self.route
def get_declarers(self):
return self.sepa_declarers

def get_base_uri(self):
return 'http://' + self.host + ':' + self.port + self.route


0 comments on commit 4c07b97

Please sign in to comment.