Re: Segentation faults when connecting to SQL Server 2000

Harri Pasanen <[email protected]>
Newsgroups gmane.comp.python.sybase
Message-ID <[email protected]>
On Tuesday 10 September 2002 10:18, hopfgartner wrote:
>
> Here we go:
>
> Traceback (most recent call last):
>   File "sqlDumpTbl.py", line 143, in ?
>     dump.dump()
>   File "sqlDump.py", line 64, in dump
>     obj_text = self.get_obj_definition(sp[0])
>   File "sqlDumpTbl.py", line 31, in get_obj_definition
>     self.sql_cursor.execute('SELECT name FROM sysobjects
> WHERE id = ' +
>   File "/usr/lib/python2.1/site-packages/Sybase.py", line
> 346, in execute
>     self._unlock()
>   File "/usr/lib/python2.1/site-packages/Sybase.py", line
> 259, in _unlock
>     self._owner._lock.release()
>   File "/usr/lib/python2.1/threading.py", line 101, in
> release
>     assert self.__owner is me, "release() of un-acquire()d
> lock"
> AssertionError: release() of un-acquire()d lock
>

I saw exactly the same thing.   If you feel adventurous you can apply the 
quick and dirty patch I have attached to effectively remove the threading 
support which I suspect you are not using anyway.

Note that the patch is in no way cleaned to be final, it just works for me.

Just copy the Sybase.py from /usr/lib/python2.2/site-packages/Sybase.py
to your test script directory, and run:

patch < Sybase.py.test-patch

Then your script has a chance of passing this hurdle...

-Harri
Sybase.py.test-patch (text/x-diff, 1.8 KB)
*** /usr/lib/python2.2/site-packages/Sybase.py	Sun Apr 21 08:00:03 2002
--- Sybase.py	Wed Sep  4 17:58:00 2002
***************
*** 136,142 ****
      raise DatabaseError(_fmt_client(msg))
  
  def _servermsg_cb(ctx, conn, msg):
!     if msg.msgnumber not in (5701,):
          raise DatabaseError(_fmt_server(msg))
  
  def _row_bind(cmd, count = 1):
--- 136,142 ----
      raise DatabaseError(_fmt_client(msg))
  
  def _servermsg_cb(ctx, conn, msg):
!     if msg.msgnumber not in (5701,5703):
          raise DatabaseError(_fmt_server(msg))
  
  def _row_bind(cmd, count = 1):
***************
*** 242,262 ****
      def __del__(self):
          if self._state not in (_CUR_IDLE, _CUR_CLOSED):
              self._owner._conn.ct_cancel(CS_CANCEL_ALL)
-         if self._lock_count:
-             # By the time we get called the threading module might
-             # have killed the thread the lock was created in ---
-             # oops.
-             count, owner = self._owner._lock._release_save()
-             self._owner._lock._acquire_restore((count, threading.currentThread()))
-             while self._lock_count:
-                 self._unlock()
  
      def _lock(self):
!         self._owner._lock.acquire()
          self._lock_count = self._lock_count + 1
  
      def _unlock(self):
!         self._owner._lock.release()
          self._lock_count = self._lock_count - 1
  
      def _raise_error(self, exc, text):
--- 242,254 ----
      def __del__(self):
          if self._state not in (_CUR_IDLE, _CUR_CLOSED):
              self._owner._conn.ct_cancel(CS_CANCEL_ALL)
  
      def _lock(self):
!         # self._owner._lock.acquire()
          self._lock_count = self._lock_count + 1
  
      def _unlock(self):
!         # self._owner._lock.release()
          self._lock_count = self._lock_count - 1
  
      def _raise_error(self, exc, text):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.