External method called twice?
Hi, I'm in trouble with zope and external methods. Sometimes (and I haven't been able to detect exactly when), my external method get called twice, even thought it is called only once from ZPT. It seems there are two independent threads accessing the same method's body. Any suggestion? Something like Java's 'synchronize'? Could someone out there help me? Thanks in advance for your patience.
Francesco Chicchiriccò wrote at 2003-4-24 10:11 +0200:
I'm in trouble with zope and external methods.
Sometimes (and I haven't been able to detect exactly when), my external method get called twice, even thought it is called only once from ZPT.
Sure, your ZPT is not called twice? External Methods are usually not called twice... Exception: when the call returns with a "TypeError", the first parameter is "self" and you pass exactly one parameter less than the necessary number of arguments, the method is called again with the context as "self" argument. However, in this case, the first call must have raised TypeError immediately, before any code of the method has been executed.
It seems there are two independent threads accessing the same method's body.
That's well possible but not a problem (unless you want to communicate via module scope variables).
Any suggestion? Something like Java's 'synchronize'?
It usually is not necessary. Read "zodb3.pdf". It explains Zopes transaction support. There is no "synchronize" but you can use looks when you really need it. After you have read the "zodb3" documentation, you will understand that locks behave differently for persistent objects. Be careful. Dieter
participants (2)
-
Dieter Maurer -
Francesco Chicchiriccò