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 serhiy.storchaka
Recipients cxss, davin, serhiy.storchaka, vinay.sajip
Date 2017-01-05.15:33:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483630438.95.0.747183196732.issue29168@psf.upfronthosting.co.za>
In-reply-to
Content
_thread.RLock objects were wrongly pickleable before 3.6.

>>> import pickle, pickletools, _thread
>>> lock = _thread.RLock()
>>> lock.acquire()
True
>>> lock
<locked _thread.RLock object owner=-1219508480 count=1 at 0xb713acb0>
>>> pickle.loads(pickle.dumps(lock))
<unlocked _thread.RLock object owner=0 count=0 at 0xb6facb90>
>>> pickletools.dis(pickletools.optimize(pickle.dumps(lock)))
    0: \x80 PROTO      3
    2: c    GLOBAL     '_thread RLock'
   17: )    EMPTY_TUPLE
   18: \x81 NEWOBJ
   19: .    STOP
highest protocol among opcodes = 2

Actually only an information about the type was saved. The state of the lock was lost. Unpickled lock was not a copy of the original lock, but a newly created object with default initial state.

There were errors in programs that pickled _thread.RLock objects. Just these errors were unnoticed. But programs likely didn't work as expected. Now an exception raised on early stage allows you to rewrite not working code. I don't know whether QueueHandler was designed to be pickleable. As a workaround try to set the lock attribute to None before pickling and set it to threading.RLock() (or call the createLock() method) after unpickling.

This change was made in issue22995.
History
Date User Action Args
2017-01-05 15:33:59serhiy.storchakasetrecipients: + serhiy.storchaka, vinay.sajip, davin, cxss
2017-01-05 15:33:58serhiy.storchakasetmessageid: <1483630438.95.0.747183196732.issue29168@psf.upfronthosting.co.za>
2017-01-05 15:33:58serhiy.storchakalinkissue29168 messages
2017-01-05 15:33:58serhiy.storchakacreate