From: Kevin J. <ja...@pe...> - 2002-07-10 15:12:12
|
Hi Dave and company, Just thought I'd let you all know that I've gotten a version of Python-Sybase-0.35pre1 + FreeTDS 0.53 to connect to MS SQL Server 2000 using TDS 7.0. In fact, it does much more than just connect! It can execute queries and seems to correctly return all of the data values I have tried. It crashes upon exit, but that is fairly problem. I'll work up diffs, though not much had to be changed. Thanks Dave! -Kevin -- -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Dave C. <dj...@ob...> - 2002-07-11 04:10:38
|
>>>>> "Kevin" == Kevin Jacobs <ja...@pe...> writes: Kevin> Hi Dave and company, Just thought I'd let you all know that Kevin> I've gotten a version of Python-Sybase-0.35pre1 + FreeTDS 0.53 Kevin> to connect to MS SQL Server 2000 using TDS 7.0. In fact, it Kevin> does much more than just connect! It can execute queries and Kevin> seems to correctly return all of the data values I have tried. Kevin> It crashes upon exit, but that is fairly problem. Kevin> I'll work up diffs, though not much had to be changed. Kevin> Thanks Dave! Thanks for putting the time into getting it to work. With one thing or another I have not been able to spend enough time on the Sybase module of late. - Dave -- http://www.object-craft.com.au |
From: Kevin J. <ja...@pe...> - 2002-07-11 04:52:54
|
On 10 Jul 2002, Dave Cole wrote: > Thanks for putting the time into getting it to work. With one thing > or another I have not been able to spend enough time on the Sybase > module of late. One thing: have you tested your modules with pymalloc? The segfault on exit only seems occur when running against pymalloc. I don't have the Sybase modules handy, so I'm trying to figure out if a double-free is coming from freetds or from the module. -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Dave C. <dj...@ob...> - 2002-07-12 02:14:36
|
>>>>> "Kevin" == Kevin Jacobs <ja...@pe...> writes: Kevin> On 10 Jul 2002, Dave Cole wrote: >> Thanks for putting the time into getting it to work. With one >> thing or another I have not been able to spend enough time on the >> Sybase module of late. Kevin> One thing: have you tested your modules with pymalloc? The Kevin> segfault on exit only seems occur when running against Kevin> pymalloc. I don't have the Sybase modules handy, so I'm trying Kevin> to figure out if a double-free is coming from freetds or from Kevin> the module. I haven't tested with pymalloc as I just use the Debian python packages for doing development. If anyone else is able to do this for me it would be very helpful. If I build a special version of Python and configure like this: configure --prefix=$HOME/debug --with-pydebug will it install files in any location other than the directory tree below my home directory? - Dave -- http://www.object-craft.com.au |
From: Kevin J. <ja...@pe...> - 2002-07-11 08:15:11
Attachments:
diff
|
On 10 Jul 2002, Dave Cole wrote: > Thanks for putting the time into getting it to work. With one thing > or another I have not been able to spend enough time on the Sybase > module of late. Attached is the diff to your Sybase module -- it includes mostly cosmetic changes, but overall, there isn't anything major. It does need to build against the latest FreeTDS CVS, since their last release is total crap. Here is the current issue I'm working on. My app is single-threaded, so I'm a little confused as to why this happens: Traceback: Traceback (most recent call last): File "./Server/connection_controller.py", line 446, in process_cmd File "./Server/connection_controller.py", line 506, in cmd_report File "/home/jacobs/projects/CGF/TradeSP/Reports/actualsummary.py", line 201, in generate D_Deductions = hash3( ts_queries.getDeductionsByCustomer(s, None, operCustomers, fy=fy) ) File "./Lib/dblib.py", line 666, in __new__ File "/home/jacobs/projects/CGF/Lib/ts_queries.py", line 3069, in run Deductions = dbcon.quickQuery(sql) File "./Lib/dblib.py", line 162, in quickQuery File "/usr/lib/python2.3/site-packages/Sybase.py", line 321, in close self._unlock() File "/usr/lib/python2.3/site-packages/Sybase.py", line 259, in _unlock self._owner._lock.release() File "/usr/lib/python2.3/threading.py", line 101, in release assert self.__owner is me, "release() of un-acquire()d lock" AssertionError: release() of un-acquire()d lock Thanks, -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Kevin J. <ja...@pe...> - 2002-07-11 08:20:32
|
On Wed, 10 Jul 2002, Kevin Jacobs wrote: > Here is the current issue I'm working on. My app is single-threaded, so I'm > a little confused as to why this happens: > > Traceback: > Traceback (most recent call last): [...] > AssertionError: release() of un-acquire()d lock Never mind -- after looking at the code, it is clear why it is blowing up. Can you explain what the unlock in the try-except block is supposed to be doing? Can that if-statement be safely deleted? def close(self): '''DB-API Cursor.close() ''' self._lock() try: if self._state == _CUR_CLOSED: self._raise_error(Error, 'cursor is closed') if self._state != _CUR_IDLE: status = self._cmd.ct_cancel(CS_CANCEL_ALL) if status == CS_SUCCEED: self._unlock() self._cmd = None self._state = _CUR_CLOSED finally: self._unlock() Thanks, -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Dave C. <dj...@ob...> - 2002-07-12 02:33:38
|
On Wed, 10 Jul 2002, Kevin Jacobs wrote: > > Here is the current issue I'm working on. My app is > > single-threaded, so I'm a little confused as to why this happens: > > > > Traceback: > > Traceback (most recent call last): > [...] > > AssertionError: release() of un-acquire()d lock > > Never mind -- after looking at the code, it is clear why it is > blowing up. Can you explain what the unlock in the try-except block > is supposed to be doing? Can that if-statement be safely deleted? > > def close(self): > '''DB-API Cursor.close() > ''' > self._lock() > try: > if self._state == _CUR_CLOSED: > self._raise_error(Error, 'cursor is closed') > if self._state != _CUR_IDLE: > status = self._cmd.ct_cancel(CS_CANCEL_ALL) > if status == CS_SUCCEED: > self._unlock() > self._cmd = None > self._state = _CUR_CLOSED > finally: > self._unlock() The Python locks are being used in a reentrant manner to make the cursors thread safe. Each method which alters the cursor object protects itself by obtaining the lock at the start of the method and releasing at the end. Some sequences of cursor operations must be keep the cursor under the control of the same thread for the entire sequence of operations. If you look at the callproc() method you will see the beginning of such a sequence: if self._state == _CUR_IDLE: # At the start of a command acquire an extra lock - # when the cursor is idle again the extra lock will be # released. self._lock() And again in the execute() method: # At the start of a command acquire an extra lock - when # the cursor is idle again the extra lock will be # released. self._lock() If you look through the rest of the cursor code you will see places where the balancing _unlock() method is called. Once all of the results have been fetched. Following it through: * Each row is fetched via the fetchone() method via the function _fetch_rows(). If no row could be fetched (None returned) the cursor has reached the end of a result set. * At the end of result set the number of rows fetched is determined via the _fetch_rowcount() method. If this method discovers that there are no more result sets (CS_END_RESULTS from ct library) it sets the cursor idle and performs the balancing _unlock() Most of the other places in the code with do the balancing _unlock() are variants of this. When you close() a cursor while there are still outstanding results then the code does the _unlock(). Likewise when there is some sort of error returned by the Sybase ct_ library. Hope this makes things a bit more clear. - Dave -- http://www.object-craft.com.au |
From: Dave C. <dj...@ob...> - 2002-07-12 02:35:51
|
>>>>> "Kevin" == Kevin Jacobs <ja...@pe...> writes: Kevin> On 10 Jul 2002, Dave Cole wrote: >> Thanks for putting the time into getting it to work. With one >> thing or another I have not been able to spend enough time on the >> Sybase module of late. Kevin> Attached is the diff to your Sybase module -- it includes Kevin> mostly cosmetic changes, but overall, there isn't anything Kevin> major. It does need to build against the latest FreeTDS CVS, Kevin> since their last release is total crap. Thank you very much for that patch. I will apply it this weekend if other family events do not prevent me. - Dave -- http://www.object-craft.com.au |
From: Kevin J. <ja...@pe...> - 2002-07-12 11:22:50
|
On 11 Jul 2002, Dave Cole wrote: > Thank you very much for that patch. I will apply it this weekend if > other family events do not prevent me. Here is another small patch for FreeTDS that really helps: --- ct.c~ Thu Jul 11 09:48:00 2002 +++ ct.c Thu Jul 11 09:48:00 2002 @@ -807,6 +807,8 @@ if (cmd->con->tds_socket) { tds_free_all_results(cmd->con->tds_socket); } + if (ret == CS_END_DATA) + ret = CS_SUCCEED; return ret; } Otherwise, ct_cancel returns CS_END_DATA instead of CS_SUCCEED. -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Dave C. <dj...@ob...> - 2002-07-12 16:43:54
|
Kevin> On 11 Jul 2002, Dave Cole wrote: Kevin> > Thank you very much for that patch. I will apply it this weekend if Kevin> > other family events do not prevent me. Kevin> Kevin> Here is another small patch for FreeTDS that really helps: Kevin> Kevin> --- ct.c~ Thu Jul 11 09:48:00 2002 Kevin> +++ ct.c Thu Jul 11 09:48:00 2002 Kevin> @@ -807,6 +807,8 @@ Kevin> if (cmd->con->tds_socket) { Kevin> tds_free_all_results(cmd->con->tds_socket); Kevin> } Kevin> + if (ret == CS_END_DATA) Kevin> + ret = CS_SUCCEED; Kevin> return ret; Kevin> } Kevin> Kevin> Otherwise, ct_cancel returns CS_END_DATA instead of CS_SUCCEED. That is awesome debugging work. Have you submitted the patch to the FreeTDS dude(s)? - Dave -- http://www.object-craft.com.au |
From: Kevin J. <ja...@pe...> - 2002-07-12 20:24:39
|
On 12 Jul 2002, Dave Cole wrote: > Kevin> On 11 Jul 2002, Dave Cole wrote: > Kevin> > Thank you very much for that patch. I will apply it this weekend if > Kevin> > other family events do not prevent me. > Kevin> > Kevin> Here is another small patch for FreeTDS that really helps: > Kevin> > Kevin> --- ct.c~ Thu Jul 11 09:48:00 2002 > Kevin> +++ ct.c Thu Jul 11 09:48:00 2002 > Kevin> @@ -807,6 +807,8 @@ > Kevin> if (cmd->con->tds_socket) { > Kevin> tds_free_all_results(cmd->con->tds_socket); > Kevin> } > Kevin> + if (ret == CS_END_DATA) > Kevin> + ret = CS_SUCCEED; > Kevin> return ret; > Kevin> } > Kevin> > Kevin> Otherwise, ct_cancel returns CS_END_DATA instead of CS_SUCCEED. > > That is awesome debugging work. > > Have you submitted the patch to the FreeTDS dude(s)? I've sent it in, but I'm not sure it is 100% correct yet -- there may be more cases that need to be mapped to CS_SUCCEED/CS_FAIL. Do you know where I could find an online spec for the CT lib? Thanks, -Kevin -- Kevin Jacobs The OPAL Group - Enterprise Systems Architect Voice: (216) 986-0710 x 19 E-mail: ja...@th... Fax: (216) 986-0714 WWW: http://www.theopalgroup.com |
From: Dave C. <dj...@ob...> - 2002-07-12 21:43:06
|
>>>>> "Kevin" == Kevin Jacobs <ja...@pe...> writes: >> Have you submitted the patch to the FreeTDS dude(s)? Kevin> I've sent it in, but I'm not sure it is 100% correct yet -- Kevin> there may be more cases that need to be mapped to Kevin> CS_SUCCEED/CS_FAIL. Do you know where I could find an online Kevin> spec for the CT lib? Try here: http://sybooks.sybase.com/cng1250e.html Specifically here: http://download.sybase.com/pdfdocs/cng1250e/ctref.pdf - Dave -- http://www.object-craft.com.au |