Multiprocessing queue in py2.7

Frank Miles fpm at
Tue Mar 28 14:51:04 EDT 2017

I tried running a bit of example code from the py2.7 docs
  ( Exchanging objects between processes)
only to have it fail.  The code is simply:
# ------------  
from multiprocessing import Process, Queue

def f(q):
    q.put([42, None, 'hello'])

if __name__ == '__main__':
    q = Queue()
    p = Process(target=f, args=(q,))
    print q.get()    # prints "[42, None, 'hello']"
# ---------------
But what happens is f() fails:

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/", line 258, in _bootstrap
  File "/usr/lib/python2.7/multiprocessing/", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "", line 4, in f
    q.put([42, None, "Hello"])
AttributeError: 'int' object has no attribute 'put'

This is on a Debian jessie host, though eventually it needs to
run on a raspberry pi 3 {and uses other library code that needs

Thanks in advance for those marvelous clues!


More information about the Python-list mailing list