On Thu, Jul 31, 2008 at 8:18 AM, binaryjesus <[EMAIL PROTECTED]> wrote:
> Is these any improvement in multi-threaded performance in the py3k
> scheduler over py2?
> >From what i know py2 runs only 1 (one) pythn thread at a time (refer 1
> below).  Another thing that i would like to see being included in
> python is auto-mutex like the java implementation. That would make my
> life much easier !!

Things have not changed with regards to Python's threading
implementation in py3k.

If you want auto-locking with function calls, there isn't a keyword
that you can just pass, but there are these magical things called
decorators that allow the easy creation of synchronized decorators...

import threading

_lock = threading.RLock()
def synchronized(fcn):
    def call(*args, **kwargs):
        with _lock:
            return fcn(*args, **kwargs)
    return call


Used like:

class foo:
    @synchronized
    def method(self, ...):
        #because of the synchronized decorator, this method is now
protected by a lock

 - Josiah
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to