Closed wangzhe3224 closed 6 years ago
The Flask framework does not work with asyncio. There are other web frameworks like tornado, aiohttp, sanic or quart that use asyncio and can be used to create REST web services.
Flask can be made to work with asyncio using tornado but this is not optimal.
Thanks for reply. Clear now.
I try to make this library a rest wrapper but get a run time error when the code try to connect IB gateway. It is good without rest.
RuntimeError: There is no current event loop in thread 'Thread-1'.
`import asyncio import json import datetime from time import time as timetime
from flask import Flask, request, jsonify from flask_restful import Resource, Api, reqparse, abort from flask.json import JSONEncoder
from ib_insync import *
class datetimeJSONEncoder(JSONEncoder):
app = Flask(name) api = Api(app)
class IbHistAPI(Resource):
api.add_resource(IbHistAPI, '/ib/getAssetHistory//')
if name == 'main':
Any could help me to figure out what is the reason for this? Thanks
Regards, ZHe