Queue between Python2 and Python3












1















I have a very simple queue which is used between Python3 modules in Raspberry Pi. I want to send messages to the same queue from one Python2 module. Does not work.



Server is running in Python3 as in this example:



from multiprocessing.managers import BaseManager
import Queue
queue = Queue.Queue()
class QueueManager(BaseManager): pass
QueueManager.register('get_queue', callable=lambda:queue)
m = QueueManager(address=('', 50000), authkey='abracadabra')
s = m.get_server()
s.serve_forever()


Sender is like this:



from multiprocessing.managers import BaseManager
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('foo.bar.org', 50000), authkey='abracadabra')
m.connect()
queue = m.get_queue()
queue.put('hello')


With both only in Python3 or in Python2 everything runs perfectly. If server is in Python3 and sender is in Python2, result is the following error:




Blockquote



Traceback (most recent call last):
File "sender_V2.py", line 22, in m.connect()
File "/usr/lib/python2.7/multiprocessing/managers.py", line 501, in connect >dispatch(conn, None, 'dummy')
File "/usr/lib/python2.7/multiprocessing/managers.py", line 102, in dispatch >kind, result = c.recv()
ValueError: unsupported pickle protocol: 3











share|improve this question


















  • 2





    Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

    – jonrsharpe
    Jan 20 at 15:30













  • It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

    – Gillespie
    Jan 20 at 18:54











  • Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

    – Juhani Miettunen
    Jan 21 at 6:55











  • This is the easiest way to go: stackoverflow.com/questions/27863832/…

    – Juhani Miettunen
    Jan 22 at 10:36
















1















I have a very simple queue which is used between Python3 modules in Raspberry Pi. I want to send messages to the same queue from one Python2 module. Does not work.



Server is running in Python3 as in this example:



from multiprocessing.managers import BaseManager
import Queue
queue = Queue.Queue()
class QueueManager(BaseManager): pass
QueueManager.register('get_queue', callable=lambda:queue)
m = QueueManager(address=('', 50000), authkey='abracadabra')
s = m.get_server()
s.serve_forever()


Sender is like this:



from multiprocessing.managers import BaseManager
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('foo.bar.org', 50000), authkey='abracadabra')
m.connect()
queue = m.get_queue()
queue.put('hello')


With both only in Python3 or in Python2 everything runs perfectly. If server is in Python3 and sender is in Python2, result is the following error:




Blockquote



Traceback (most recent call last):
File "sender_V2.py", line 22, in m.connect()
File "/usr/lib/python2.7/multiprocessing/managers.py", line 501, in connect >dispatch(conn, None, 'dummy')
File "/usr/lib/python2.7/multiprocessing/managers.py", line 102, in dispatch >kind, result = c.recv()
ValueError: unsupported pickle protocol: 3











share|improve this question


















  • 2





    Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

    – jonrsharpe
    Jan 20 at 15:30













  • It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

    – Gillespie
    Jan 20 at 18:54











  • Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

    – Juhani Miettunen
    Jan 21 at 6:55











  • This is the easiest way to go: stackoverflow.com/questions/27863832/…

    – Juhani Miettunen
    Jan 22 at 10:36














1












1








1








I have a very simple queue which is used between Python3 modules in Raspberry Pi. I want to send messages to the same queue from one Python2 module. Does not work.



Server is running in Python3 as in this example:



from multiprocessing.managers import BaseManager
import Queue
queue = Queue.Queue()
class QueueManager(BaseManager): pass
QueueManager.register('get_queue', callable=lambda:queue)
m = QueueManager(address=('', 50000), authkey='abracadabra')
s = m.get_server()
s.serve_forever()


Sender is like this:



from multiprocessing.managers import BaseManager
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('foo.bar.org', 50000), authkey='abracadabra')
m.connect()
queue = m.get_queue()
queue.put('hello')


With both only in Python3 or in Python2 everything runs perfectly. If server is in Python3 and sender is in Python2, result is the following error:




Blockquote



Traceback (most recent call last):
File "sender_V2.py", line 22, in m.connect()
File "/usr/lib/python2.7/multiprocessing/managers.py", line 501, in connect >dispatch(conn, None, 'dummy')
File "/usr/lib/python2.7/multiprocessing/managers.py", line 102, in dispatch >kind, result = c.recv()
ValueError: unsupported pickle protocol: 3











share|improve this question














I have a very simple queue which is used between Python3 modules in Raspberry Pi. I want to send messages to the same queue from one Python2 module. Does not work.



Server is running in Python3 as in this example:



from multiprocessing.managers import BaseManager
import Queue
queue = Queue.Queue()
class QueueManager(BaseManager): pass
QueueManager.register('get_queue', callable=lambda:queue)
m = QueueManager(address=('', 50000), authkey='abracadabra')
s = m.get_server()
s.serve_forever()


Sender is like this:



from multiprocessing.managers import BaseManager
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('foo.bar.org', 50000), authkey='abracadabra')
m.connect()
queue = m.get_queue()
queue.put('hello')


With both only in Python3 or in Python2 everything runs perfectly. If server is in Python3 and sender is in Python2, result is the following error:




Blockquote



Traceback (most recent call last):
File "sender_V2.py", line 22, in m.connect()
File "/usr/lib/python2.7/multiprocessing/managers.py", line 501, in connect >dispatch(conn, None, 'dummy')
File "/usr/lib/python2.7/multiprocessing/managers.py", line 102, in dispatch >kind, result = c.recv()
ValueError: unsupported pickle protocol: 3








python python-3.x






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 20 at 15:24









Juhani MiettunenJuhani Miettunen

61




61








  • 2





    Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

    – jonrsharpe
    Jan 20 at 15:30













  • It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

    – Gillespie
    Jan 20 at 18:54











  • Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

    – Juhani Miettunen
    Jan 21 at 6:55











  • This is the easiest way to go: stackoverflow.com/questions/27863832/…

    – Juhani Miettunen
    Jan 22 at 10:36














  • 2





    Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

    – jonrsharpe
    Jan 20 at 15:30













  • It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

    – Gillespie
    Jan 20 at 18:54











  • Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

    – Juhani Miettunen
    Jan 21 at 6:55











  • This is the easiest way to go: stackoverflow.com/questions/27863832/…

    – Juhani Miettunen
    Jan 22 at 10:36








2




2





Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

– jonrsharpe
Jan 20 at 15:30







Python 2 can't deserialise data pickled by Python 3 using the latest protocol, see e.g. docs.python.org/3/library/pickle.html#data-stream-format. There's a workaround here, but you might be better using a proper external queue where you can control the serialisation format. See also stackoverflow.com/q/54135972/3001761

– jonrsharpe
Jan 20 at 15:30















It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

– Gillespie
Jan 20 at 18:54





It might be easier to just use language agnostic MQ like ZeroMQ, Protobufs, or even just simple JSON over UDP.

– Gillespie
Jan 20 at 18:54













Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

– Juhani Miettunen
Jan 21 at 6:55





Unfortunately changing the existing solution to something new is too much work. It is surprising that compatibility mode between between Python 2 and Python 3 is not available. Should not be too difficult, because the same code using queue works exactly the same way in both pythons. Naturally with the known syntax changes.

– Juhani Miettunen
Jan 21 at 6:55













This is the easiest way to go: stackoverflow.com/questions/27863832/…

– Juhani Miettunen
Jan 22 at 10:36





This is the easiest way to go: stackoverflow.com/questions/27863832/…

– Juhani Miettunen
Jan 22 at 10:36












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277946%2fqueue-between-python2-and-python3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277946%2fqueue-between-python2-and-python3%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Homophylophilia

Updating UILabel text programmatically using a function

Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage