ODM2 / WOFpy

A server-side implementation of CUAHSI's Water One Flow service stack in Python.
http://odm2.github.io/WOFpy/
9 stars 9 forks source link

Multithreading error on ODM2 SQLite and MySQL when trying to implement odm2api-based queries #112

Open lsetiawan opened 7 years ago

lsetiawan commented 7 years ago

This is following up to previous issue on SQLite after dao was updated to use odm2api querying engine. A test was done on MySQL Little Bear Database, and when the server is live I am getting

Error running Query: (pymysql.err.InternalError) Packet sequence number wrong - got 109 expected 1 ...

This is similar to issue 75 for SQLite.

After some research, I get to the same conclusion of queries not being closed each time it's done. This causes the multithreading errors.

Resource:

emiliom commented 7 years ago

Thanks, @lsetiawan. Darn. I'll try to take a look later.

lsetiawan commented 7 years ago

One difference I see between how the wofpy dao is querying is that scoped_session is used, but odm2api is not using that.

scoped_session is an approach for Session Management. Without scoped_session, the session doesn't seem to close at the end of a request. Causing a multithreading error.

Resource:

emiliom commented 7 years ago

Just for reference: this issue is linked to PR #111. See that PR (now closed) for related discussions.

sreeder commented 7 years ago

@lsetiawan the newest odm2api release is using the scoped_session.

lsetiawan commented 7 years ago

@sreeder Woo hoo! Great! Thanks 😄

emiliom commented 7 years ago

@sreeder I noticed this in the notes to the odm2api release. That's great, and thanks for letting us know here.

We're very close to a new wofpy release. To minimize uncertainties and new work, I'd rather keep odm2api querying out of this release, and stick to the current approach (almost pure SQLAlchemy, except for importing and using odm2api.ODM2.models). Then after the release we can revisit odm2api integration.