[Zope] threading
 boundary="------------89058EF200FCB3C4EA85CC71"
   
    Dieter Maurer
     
    dieter@handshake.de
       
    Mon,  7 Aug 2000 20:25:49 +0200 (CEST)
    
    
  
Nicholas Lo writes:
 > According to Amos' How-To: Thread Safety in Zope 2, what is mutable
 > global or shared variables?? What is the scope of such global variables?
 > Zope wide? module wide?
I did not read this How-To. Thus, be careful with my explanation.
A mutable object is one that can change its value over time.
E.g. a list is mutable (you can "append", "insert", "delete" elements)
while a tuple is not.
If several threads concurrently access a mutable object
(or a mutable binding, i.e. a name (variable) is bound to
different values over time), results can be quite unpredictable.
Usually, you would use a synchronization mechanism to
control access to objects. See the Python modules
"thread" and "threading" for functions available for this
purpose.
 > If global variable is not permitted, how can I approach thread
 > programming in Zope? Without global variables, how can I control
 > threads?
You can use global variables -- provided you know what you
do and ensure proper synchronization.
You may want to look at "ZODB.Transaction.get_transaction"
to learn how Zope itself manages its transaction context
in view of serveral threads.
Dieter
PS: I do not like MIME messages in this list.
    The list software strips MIME headers and my mail reader is
    therefore unable to decode the message.