I'm using pymssql as part of a custom plugin for Trac (issue/ticket system -- http://trac.edgewall.org\). Specifically, the plugin is going to a MSSQL database of users so that it can build a list of possible Trac ticket owners. Occasionally, I get errors where a Trac ticket page load fails; digging has winnowed the culprits down to the pymssql libs DB connection attempt.
The error from the log is:
> File "c:\python25\lib\site-packages\pymssql.py", line 328, in connect
> con = _mssql.connect(dbhost, dbuser, dbpasswd)
> error: DB-Lib error message 10005, severity 1:
> DBPROCESS is dead or not enabled.
The code is written such that a single connection is shared among requests, with new cursors created/destroyed for each request. The problem seems to occur, perhaps not surprisingly, when Apache kills off a child process and starts up a new one. Is there some command/state in the pymssql lib that I can check before attempting to use the pymssql connection, to detect that it's "dead" and needs to be re-established? Or am I going completely off in the wrong direction?
Platform:
- Windows Server 2003
- Apache/2.2.4 (Win32)
- Python 2.5.1
- pymssql 0.8.0
- Trac 0.11dev-r6306
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd recommend against persistent connections, because the problem you're observing right now is typical. They cannot be shared among Apache processes if they aren't specifically written to be shared. And neither I nor the former author, Joon-cheol Park haven't written them that way.
Just open the connection at the beginning of the script and close it at the end.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using pymssql as part of a custom plugin for Trac (issue/ticket system -- http://trac.edgewall.org\). Specifically, the plugin is going to a MSSQL database of users so that it can build a list of possible Trac ticket owners. Occasionally, I get errors where a Trac ticket page load fails; digging has winnowed the culprits down to the pymssql libs DB connection attempt.
The error from the log is:
> File "c:\python25\lib\site-packages\pymssql.py", line 328, in connect
> con = _mssql.connect(dbhost, dbuser, dbpasswd)
> error: DB-Lib error message 10005, severity 1:
> DBPROCESS is dead or not enabled.
The code is written such that a single connection is shared among requests, with new cursors created/destroyed for each request. The problem seems to occur, perhaps not surprisingly, when Apache kills off a child process and starts up a new one. Is there some command/state in the pymssql lib that I can check before attempting to use the pymssql connection, to detect that it's "dead" and needs to be re-established? Or am I going completely off in the wrong direction?
Platform:
- Windows Server 2003
- Apache/2.2.4 (Win32)
- Python 2.5.1
- pymssql 0.8.0
- Trac 0.11dev-r6306
I'd recommend against persistent connections, because the problem you're observing right now is typical. They cannot be shared among Apache processes if they aren't specifically written to be shared. And neither I nor the former author, Joon-cheol Park haven't written them that way.
Just open the connection at the beginning of the script and close it at the end.