Open hotea opened 6 years ago
and the script of the TradingAlgorithm is: https://github.com/quantopian/zipline/blob/master/zipline/examples/dual_ema_talib.py
Are you using threaded workers in your wsgi server? This issue is happening because you are creating the data portal in a different thread than you are using it.
One fix could be to store the data portal on a threading.local to ensure that it is only ever used in a single thread.
but is there any zipline api used to control the sqlite connection? I did't find one...
Dear Zipline Maintainers,
Before I tell you about my issue, let me describe my environment:
Environment
Darwin localhost 16.7.0 Darwin Kernel Version 16.7.0: Tue Jan 30 11:27:06 PST 2018; root:xnu-3789.73.11~1/RELEASE_X86_64 x86_64
3.16.0 2016-11-04 19:09:39 0e5ffd9123d6d2d2b8f3701e8a73cc98a3a7ff5f
Python 3.6.4
64
pip
)alembic==0.9.9 aniso8601==3.0.0 appnope==0.1.0 backcall==0.1.0 bcolz==0.12.1 Bottleneck==1.2.1 certifi==2018.1.18 chardet==3.0.4 click==6.7 contextlib2==0.5.5 cyordereddict==1.0.0 Cython==0.28.1 decorator==4.2.1 empyrical==0.4.2 Flask==0.12.2 Flask-Admin==1.5.1 Flask-Mako==0.4 flask-marshmallow==0.8.0 Flask-Migrate==2.1.1 Flask-RESTful==0.3.6 Flask-SQLAlchemy==2.3.2 idna==2.6 intervaltree==2.1.0 ipython==6.3.1 ipython-genutils==0.2.0 itsdangerous==0.24 jedi==0.11.1 Jinja2==2.10 Logbook==1.3.0 lru-dict==1.1.6 Mako==1.0.7 MarkupSafe==1.0 marshmallow==2.15.0 marshmallow-sqlalchemy==0.13.2 multipledispatch==0.5.0 networkx==1.11 nose==1.3.7 numexpr==2.6.4 numpy==1.14.2 pandas==0.18.1 pandas-datareader==0.5.0 parso==0.1.1 patsy==0.5.0 pexpect==4.5.0 pickleshare==0.7.4 prompt-toolkit==1.0.15 psycopg2==2.7.4 psycopg2-binary==2.7.4 ptyprocess==0.5.2 Pygments==2.2.0 python-dateutil==2.7.2 python-editor==1.0.3 pytz==2018.4 requests==2.18.4 requests-file==1.4.3 requests-ftp==0.3.1 scipy==1.0.1 simplegeneric==0.8.1 six==1.11.0 sortedcontainers==1.5.9 SQLAlchemy==1.2.6 statsmodels==0.8.0 TA-Lib==0.4.17 tables==3.4.2 toolz==0.9.0 traitlets==4.3.2 urllib3==1.22 wcwidth==0.1.7 Werkzeug==0.14.1 WTForms==2.1 zipline==1.2.0
Now that you know a little about me, let me tell you about the issue I am having:
Description of Issue
What happened instead?
Here is how you can reproduce this issue on your machine:
Reproduction Steps
i use zipline api in flask web framework
What steps have you taken to resolve this already?
I temporarily modified the function
check_and_create_connection
of the library file/VIRTUALENV_NAME/lib/python3.6/site-packages/zipline/utils/sqlite_utils.py
.add a perameter
check_same_thread=False
tosqlite3.connect()
...Anything else?
Thanks in advance