[Zope] import threading.Lock --> unpickleable

Thomas Guettler zopestoller@thomas-guettler.de
Thu, 18 Apr 2002 15:50:48 +0200


Sorry, ignore this email. I think the problem was that
I forgot to release the lock

  thomas

Thomas Guettler wrote:

> I was told that it is possible to syncronise
> several zope-request with methods from the python
> library.
> 
> But it is not that easy:
> 
> If you try to add a threading.Lock() instance to
> a python class you get:
> 
> Error Type: UnpickleableError
> Error Value: Cannot pickle objects
> 
> This means, you have to store it in an volatile
> attribute. I tried it like this. But this
> hangs if I delete the object which has
> the Lock as_v_lock instance.
> 
> 
>    def acquireLock(self):
>         print "StollDMS.acquireLock"
>         lock=getattr(self, "_v_lock", None)
>         if not lock:
>             self._v_lock=threading.Lock()
>             lock=self._v_lock
>         lock.acquire()
> 
>     def releaseLock(self):
>         # acquire() should have been called
>         # about one second before. This means the volatile lock
>         # should still be there
>         print "StollDMS.releaseLock"
>         self._v_lock.release()
> 
> Any ideas?
> 
>  thomas
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
> 
> 
>