This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author allenap
Recipients allenap
Date 2009-11-27.11:42:39
SpamBayes Score 3.119168e-05
Marked as misclassified No
Message-id <1259322161.32.0.385116687037.issue7403@psf.upfronthosting.co.za>
In-reply-to
Content
The logging module create a global _lock in what looks like a
thread-unsafe manner:

{{{
_lock = None

def _acquireLock():
    """
    Acquire the module-level lock for serializing access to shared data.

    This should be released with _releaseLock().
    """
    global _lock
    if (not _lock) and thread:
        _lock = threading.RLock()
    if _lock:
        _lock.acquire()
}}}

If two threads call _acquireLock() at the same time, and _lock is
None, it's possible that two locks will be created, one of which will
get clobbered.

I think the above could be made thread-safe if written as:

{{{
if thread:
    _lock = threading.RLock()
else:
    _lock = None

def _acquireLock():
    """
    Acquire the module-level lock for serializing access to shared data.

    This should be released with _releaseLock().
    """
    if _lock:
        _lock.acquire()
}}}
History
Date User Action Args
2009-11-27 11:42:41allenapsetrecipients: + allenap
2009-11-27 11:42:41allenapsetmessageid: <1259322161.32.0.385116687037.issue7403@psf.upfronthosting.co.za>
2009-11-27 11:42:39allenaplinkissue7403 messages
2009-11-27 11:42:39allenapcreate