Hello all

I'm experiencing frequent deadlocks in my cherrypy/sqlobject multithreaded
server application. I'm unable to reproduce the error in a small-scale
example yet, but one thing I noticed is, that it might be related to me
creating other sqlobjects in an overwritten _create() function.

What I see is that various threads try to acquire a threadSafeMethod
decorator's lock, originating from various places:

...
  File "/usr/lib/python2.4/site-packages/sqlobject/sresults.py", line 165,
in __iter__
    return iter(list(self.lazyIter()))
  File "/usr/lib/python2.4/site-packages/sqlobject/dbconnection.py", line
804, in next
    obj = self.select.sourceClass.get(result[0], selectResults=result[1:],
connection=self.dbconn)
  File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 915, in
get
    val = cls(_SO_fetch_no_create=1)
  File "/usr/lib/python2.4/site-packages/sqlobject/declarative.py", line
92, in _wrapper
    lock.acquire()
  File "threading.py", line 100, in acquire
    rc = self.__block.acquire(blocking)

And one thread is pending on the cache's lock:

...
  File "/usr/lib/python2.4/site-packages/sqlobject/declarative.py", line
94, in _wrapper
    return fn(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 1214, in
__init__
    self._create(id, **kw)
  File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 1245, in
_create
    self._SO_finishCreate(id)
  File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 1271, in
_SO_finishCreate
    cache.created(id, self.__class__, self)
  File "/usr/lib/python2.4/site-packages/sqlobject/cache.py", line 300, in
created
    self.caches[cls.__name__].created(id, obj)
  File "/usr/lib/python2.4/site-packages/sqlobject/cache.py", line 177, in
created
    self.cull()
  File "/usr/lib/python2.4/site-packages/sqlobject/cache.py", line 190, in
cull
    self.lock.acquire()

.. originating from a certain _create function (hence my assumption).

My create() is looking quite straight-forward, something like this:

class MyClass(sqlobject):
      foo = ForeignKey('OtherClass', default=None)
      bar = ForeignKey('OtherClass', default=None)

      def _create(self, *args, **kw):
            # Create the object
            super(MyClass, self)._create(*args, **kw)

                  # Create other object
            self.foo = OtherClass()
            self.bar = OtherClass()

So, my question is: is this problematic, and, if yes, what other ways are
there to do it?

Thanks a million
Bernhard


... and, sorry for the mess:
___________________________________________________________________

Disclaimer:


Diese Mitteilung ist nur fuer die Empfaengerin / den Empfaenger bestimmt.

Fuer den Fall, dass sie von nichtberechtigten Personen empfangen wird,
bitten wir diese hoeflich, die Mitteilung an die ZKB zurueckzusenden und
anschliessend die Mitteilung mit allen Anhaengen sowie allfaellige Kopien
zu vernichten bzw. zu loeschen. Der Gebrauch der Information ist verboten.


This message is intended only for the named recipient and may contain
confidential or privileged information.

If you have received it in error, please advise the sender by return e-mail
and delete this message and any attachments. Any unauthorised use or
dissemination of this information is strictly prohibited.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to