Hi All More details on the session issue;
Please note, the test I just did was this; Restart the mySQL server. Start Process #1 and create a session and use it (works fine) Start Process #2 (Identical code to #1, just another instance). Go back to #1 and attempt to do another query and I get this; File "Z:\warwickprince On My Mac\Desktop\Code Developement\MSI\Clear Enterprise\DAP2 Python\trunk\DAPForm.py", line 2556, in _moveToRow self._formInstance._currentRowProxy = self._query[self._currentPosition] # Get the one at that position File "C:\Python26\lib\site-packages\sqlalchemy\orm\query.py", line 1446, in __getitem__ return list(self[item:item+1])[0] File "C:\Python26\lib\site-packages\sqlalchemy\orm\query.py", line 1444, in __getitem__ return list(res) File "C:\Python26\lib\site-packages\sqlalchemy\orm\query.py", line 1604, in __iter__ return self._execute_and_instances(context) File "C:\Python26\lib\site-packages\sqlalchemy\orm\query.py", line 1609, in _execute_and_instances mapper=self._mapper_zero_or_none()) File "C:\Python26\lib\site-packages\sqlalchemy\orm\session.py", line 701, in execute clause, params or {}) File "C:\Python26\lib\site-packages\sqlalchemy\engine\base.py", line 1194, in execute params) File "C:\Python26\lib\site-packages\sqlalchemy\engine\base.py", line 1272, in _execute_clauseelement parameters=params File "C:\Python26\lib\site-packages\sqlalchemy\engine\base.py", line 1380, in __create_execution_context connection=self, **kwargs) File "C:\Python26\lib\site-packages\sqlalchemy\engine\default.py", line 381, in __init__ self.cursor = self.create_cursor() File "C:\Python26\lib\site-packages\sqlalchemy\engine\default.py", line 523, in create_cursor return self._connection.connection.cursor() File "C:\Python26\lib\site-packages\sqlalchemy\engine\base.py", line 920, in connection "Can't reconnect until invalid " InvalidRequestError: Can't reconnect until invalid transaction is rolled back BTW: self._query is self._Session.Query(Product) I can't quite get my head around the "scope" of sessionmaker() yet.. I've tried putting Session = sessionmaker() as a global to the entire codebase (works but has same problem) I've put it inside the process code so that it can not share any state or memory with the other one(s) (This is the current config) and yet it's immediately trashing the first session as soon as I create a second. I'm only *reading* from either of the sessions at this stage, so there is actually no pending data or writes being done what-so-ever, so I don't know what transaction should be rolled back or why it's invalid. The connection (created in the same myManager class) used for direct table.select() operations still works fine even after the above error happens. Importantly.. I can completely close all my processes and cold start my code - and this error continues until I restart mySQL ! i.e. NO session will work again, but I can do basic queries. What the?! Hope someone can shed some light on this one :-S BTW: It someone says "You should be using scoped_session.." Please explain how to have either more than one session in the same context (I use three for a possible three different binds) or how to create one session that I can bind to more than one engine, and not have to know in advance all possible tables I might want to use on each engine.. This is a generic session that I want to be able to use for all tables in the bound engine - thus three sessions given that is the maximum possible choices of DB in this scenario. What if I don't bind a session to any engine.. Does it then follow the bind on the mapped table class for a given query? Cheers Warwick On 6 October 2010 20:02, Warwick Prince <warwi...@mushroomsys.com> wrote: > Hi Chris > > It's simply trapped as a > > except Exception as message: > > I'll see what I can do - Just a mo.. > > Cheers > Warwick > > > On 6 October 2010 19:54, Chris Withers <ch...@simplistix.co.uk> wrote: > >> On 06/10/2010 10:46, Warwick Prince wrote: >> >>> (InterfaceError) 2055: Lost connection to MySQL server at >>> '192.168.50.2:3306 <http://192.168.50.2:3306>', system error: 10054 >>> u'SELECT products...... >>> >> >> ...it would be interesting to see the rest of that error message... >> >> Chris >> > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.