question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot pickle objects when using unix socket

See original GitHub issue

One of my use-cases is loading a list of containers in one process and then pushing them to be processed in another process, using a standard python queue.

While this method works well with the tcp:// socket, when using the unix:// socket the pickler will throw the following exception:

    queue.put((QUEUE_OBJ, obj), block=block)
  File "<string>", line 2, in put
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 756, in _callmethod
    conn.send((self._id, methodname, args, kwds))
  File "/usr/local/lib/python3.6/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/usr/local/lib/python3.6/multiprocessing/reduction.py", line 51, in dumps
    cls(buf, protocol).dump(obj)
AttributeError: Can't pickle local object 'UnixAdapter.__init__.<locals>.<lambda>'

On one hand I could just push the IDs of the objects downstream, but I need some of the attributes belonging to the Containers as well, and it makes for quite an inconvenient way of sharing them.

I am not sure if that is the expected behaviour; but the TCP protocol works well enough and I can’t see a reason why UNIX should not.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
drzrafcommented, Apr 21, 2020

maintainers? I’m still annoyed of not being able to work on docker-py containers within concurrent.

2reactions
jason-kanecommented, May 18, 2021

Not being able to use multiprocess w/docker api calls is lame. Not doing it out of some misguided stubborn refusal when the fix is near-trivial is ridiculous.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot pickle objects when using unix socket -
One of my use-cases is loading a list of containers in one process and then pushing them to be processed in another process,...
Read more >
A copied socket is not being pickled - python
The socket is created in rust and is shared as a Python object through PyO3. Here is the shared socket code use pyo3::prelude::*;...
Read more >
Serialization of un-picklable objects
First, define functions which cannot be pickled with the standard pickle protocol. They cannot be serialized with pickle because they are defined in...
Read more >
sending and receiving Python Objects with sockets
We've learned how to send and receive string data via sockets, and now I want to talk about is pickles. Not the food,...
Read more >
How to set up a 'listening' Unix domain socket
import os from socketserver import UnixStreamServer, ... if os.path.exists(SOCKET): os.unlink(SOCKET) with ... Pickled object works fine
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found