New submission from Robin Schoonover <e...@cornhooves.org>:

The multiprocessing module's version of the Queue class, which causes objects 
to be pickled for process to process transfer, ignores pickle restrictions when 
objects are added to the queue.  Example code (buffer isn't pickleable):

    from multiprocessing import Queue

    q = Queue()
    q.put(buffer("this is a buffer"))
    print(q.get())

It results in an exception, which is expected, but the exception is confusing, 
after the problem has already occurred, and if I were actually using multiple 
processes, not in the process that tried to send an unsendable object:

Traceback (most recent call last):                                              
             
  File "mppkbuffer.py", line 5, in <module>                                     
           
    print(q.get())
  File "/usr/lib/python2.6/multiprocessing/queues.py", line 91, in get
    res = self._recv()
TypeError: buffer() takes at least 1 argument (0 given)

Expected result would be a thrown exception when we attempt to put the object 
into the queue using .put(), NOT when we attempt pull it out of the queue using 
.get(), when it gets unpickled.  Basically, while pickle fails when it tries to 
dump, Queue succeeds the dump (somehow) and fails to load.

I have tested with python 2.6.4 and 2.7a4.  3.1 doesn't appear to have this bug 
(but it does have a different one which I will report later).

----------
components: Library (Lib)
messages: 102423
nosy: rschoon
severity: normal
status: open
title: multiprocessing.Queue ignores pickle restrictions in .put()
type: behavior
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8323>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to