Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 烧瓶运行函数RuntimeError“;线程';中没有当前事件循环;“线程”;_Python 3.x_Flask - Fatal编程技术网

Python 3.x 烧瓶运行函数RuntimeError“;线程';中没有当前事件循环;“线程”;

Python 3.x 烧瓶运行函数RuntimeError“;线程';中没有当前事件循环;“线程”;,python-3.x,flask,Python 3.x,Flask,我有一个flask应用程序(python3.7),它调用函数并以纯文本形式返回股票数据。 脚本在自己的.py中运行时工作正常(从stock.screener导入screener>>stock\u list=screener(filters=filters,order='price',table='Overview')。 但是,在flask应用程序中,我发现以下错误: 线程“thread-2”中没有当前事件循环。 **尝试了这里的一切来让它工作——asyncio,只是在杂草中编码 尝试了异步、异步

我有一个flask应用程序(python3.7),它调用函数并以纯文本形式返回股票数据。 脚本在自己的.py中运行时工作正常(从stock.screener导入screener>>stock\u list=screener(filters=filters,order='price',table='Overview')。 但是,在flask应用程序中,我发现以下错误: 线程“thread-2”中没有当前事件循环。 **尝试了这里的一切来让它工作——asyncio,只是在杂草中编码

尝试了异步、异步..我只是被杂草缠住了-提前谢谢

from flask import Flask
from stock.screener import Screener

app = Flask(__name__)

@app.route('/')
def check_server():
    return "Server is Running!"

@app.route('/test')
def run_screener():

    try:
        r = Screener(filters=['cap_nano','sh_avgvol_o200','sh_price_u10','sh_relvol_o2','sh_short_u30','ta_rsi_os40'], order='price', table='Overview')
        return r
    except Exception as e: 
        return str(e), 500


if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')
预期结果:

No. | Ticker | Company                           | Sector          | Industry                            | Country        | Market Cap | P/E  | Price | Change  | Volume    
--- | ------ | --------------------------------- | --------------- | ----------------------------------- | -------------- | ---------- | ---- | ----- | ------- | ----------
1   | OHGI   | One Horizon Group, Inc.           | Technology      | Application Software                | United Kingdom | 1.44M      | -    | 0.02  | -8.57%  | 660,189   
2   | LODE   | Comstock Mining Inc.              | Basic Materials | Gold                                | USA            | 11.57M     | -    | 0.13  | -9.29%  | 4,668,153 
3   | VIVE   | Viveve Medical, Inc.              | Healthcare      | Medical Appliances & Equipment      | USA            | 6.58M      | -    | 0.13  | -8.47%  | 6,520,180 
4   | UPL    | Ultra Petroleum Corp.             | Basic Materials | Independent Oil & Gas               | USA            | 26.65M     | 0.34 | 0.14  | -21.10% | 14,748,106