Open wanghaiqing2015 opened 7 years ago
set use_reloader to False, it can works.
app.run(host='0.0.0.0',port=2133,use_reloader=False)
@wanghaiqing2015 this is because you have to manually open up and close the connection in flask.
@gi0baro what your mean?
Is my code any problem?
@gi0baro How to solve it?
@wanghaiqing2015 you have to write a middleware that should be executed on every route. When request arrives you should call db._adapter.reconnect()
and when you completed the response you should call db._adapter.close()
.
ok
@wanghaiqing2015 for more details you can check the weppy database pipe and try to convert it to the flask middlewares: https://github.com/gi0baro/weppy/blob/release/weppy/orm/base.py#L30#L44
@gi0baro the correct link is https://github.com/gi0baro/weppy/blob/release/weppy/orm/base.py#L31#L45
@ichux actually those lines depends on weppy implementation of pydal. The best reference is https://github.com/gi0baro/weppy/blob/v1.1.2/weppy/orm/base.py#L29#L43 Those lines are valid with vanilla pydal
shows: AttributeError: 'thread._local' object has no attribute '_pydal_connection_65073872_18848'
but use pydal 16.3 or not in debug mode, it can works.
========================================================
File "C:\Python27\lib\site-packages\pydal\objects.py", line 2210, in select return adapter.select(self.query, fields, attributes) File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 760, in select return self._select_aux(sql, fields, attributes, colnames) File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 716, in _select_aux rows = self._select_aux_execute(sql) File "C:\Python27\lib\site-packages\pydal\adapters\base.py", line 710, in _select_aux_execute self.execute(sql) File "C:\Python27\lib\site-packages\pydal\adapters__init__.py", line 63, in wrap if not args[0].connection: File "C:\Python27\lib\site-packages\pydal\connection.py", line 36, in connection return getattr(THREAD_LOCAL, self._connectionuname) AttributeError: 'thread._local' object has no attribute '_pydal_connection_64199056_28088' 'thread._local' object has no attribute '_pydal_connection_64199056_28088'