Issue #9945: logging: backported locking fixes from py3k.
Issue #9945: logging: backported locking fixes from py3k.

sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator