Re: [Zope-dev] Transaction question

2000-08-28 Thread Erik Enge

[Shane Hathaway]

| It means that a correctly operating ZODB will behave this way.

Oh, I see.  Thanks for clarifying that.  :)

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Transaction question

2000-08-28 Thread Johan Carlsson

> > | >
> > | > I just want to check if things work the way I think (hope) it does.
> > | >
> > | > In a transaction, are objects attributes safe from other threads.
> > | >
> > | > self._v_mytemp in my request does not conflict with other requests?
> > |
> > | This is correct (or it's supposed to be.)
> > 
> > What do you mean by "supposed to be"?  Is it, or is it not correct?
> 
> It means that a correctly operating ZODB will behave this way.  I
> suspected that Johan may have been facing some kind of ZODB bug,
> therefore I qualified my statement.  The phrasing was designed to
> elicit a response if he were indeed facing a defect.

I haven't experienced any problems so far, but I havn't tested it yet either.
The reason I asked was to not make any stupied assumptions before starting
coding.
If I experience any problems I'll let you know, naturally :-)

Cheers,
JOhan



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Transaction question

2000-08-28 Thread Shane Hathaway

Erik Enge wrote:
> 
> [Shane Hathaway]
> 
> | Johan Carlsson wrote:
> | >
> | > I just want to check if things work the way I think (hope) it does.
> | >
> | > In a transaction, are objects attributes safe from other threads.
> | >
> | > self._v_mytemp in my request does not conflict with other requests?
> |
> | This is correct (or it's supposed to be.)
> 
> What do you mean by "supposed to be"?  Is it, or is it not correct?

It means that a correctly operating ZODB will behave this way.  I
suspected that Johan may have been facing some kind of ZODB bug,
therefore I qualified my statement.  The phrasing was designed to
elicit a response if he were indeed facing a defect.

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Transaction question

2000-08-28 Thread Erik Enge

[Shane Hathaway]

| Johan Carlsson wrote:
| > 
| > I just want to check if things work the way I think (hope) it does.
| > 
| > In a transaction, are objects attributes safe from other threads.
| > 
| > self._v_mytemp in my request does not conflict with other requests?
| 
| This is correct (or it's supposed to be.) 

What do you mean by "supposed to be"?  Is it, or is it not correct?

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




RE: [Zope-dev] Transaction question

2000-08-28 Thread Chris McDonough

Using a mutex by way of example, without using anything Zope-specific
(the following uses the Python threading module):

import threading
lock = threading.Lock()
myglobal = []

def changeglobal(val):
lock.acquire()
try:
myglobal.append(val)
finally:
lock.release()

> > (I suppose class attributes needs to be protected to be thread-safe?
> >  Does anybody have an example how to do that?)
> 
> You can use allocate_lock() to accomplish thread safety with class
> attributes.

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] Transaction question

2000-08-28 Thread Shane Hathaway

Johan Carlsson wrote:
> 
> I just want to check if things work the way I think (hope) it does.
> 
> In a transaction, are objects attributes safe from other threads.
> 
> self._v_mytemp in my request does not conflict with other requests?

This is correct (or it's supposed to be.)  Each thread has its own copy
of the objects, so in most cases, all instance attributes are thread
safe.

> (I suppose the have to be otherwise REQUEST's would interfere with each other.)
> 
> I know that _v_* attributes aren't persistent but do they remain active in memory
> and there by accessible to other requests after the transaction commit?

They do remain after the commit.  But when the objects are removed from
the in-memory cache the _v_* attributes will vanish.

> (I suppose class attributes needs to be protected to be thread-safe?
>  Does anybody have an example how to do that?)

You can use allocate_lock() to accomplish thread safety with class
attributes.

Shane

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )