我正在尝试搭建一个简单的flask
服务器:
import envkey
import pysher
from flask import Flask
# from predictor import PythonPredictor
app = Flask(__name__)
pusher = pysher.Pusher(envkey.get('PUSHER_KEY'))
def my_func(*args, **kwargs):
print("processing Args:", args)
print("processing Kwargs:", kwargs)
# We can't subscribe until we've connected, so we use a callback handler
# to subscribe when able
def connect_handler(data):
print('connect habndler')
channel = pusher.subscribe('mychannel')
channel.bind('myevent', my_func)
pusher.connection.bind('pusher:connection_established', connect_handler)
@app.route('/')
def index():
pusher.connect()
return 'Server Works!'
但是我遇到了一个错误:
RuntimeError: cannot join current thread
我做错了什么?
ps -aux
命令验证一下吗?如果它已经在运行,请杀掉该进程。 - Ashwin Geet D'Sapusher.connect()
语句调用该端点时? - errata