Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #110296

Re: Cassandra multiprocessing can't pickle _thread.lock objects

From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: Cassandra multiprocessing can't pickle _thread.lock objects
Date 2016-06-22 08:13 +0200
Message-ID <mailman.27.1466576961.11516.python-list@python.org> (permalink)
References <CAF_EDksR2jqOW9gz1ij2P6XZHq=hEjsftbzmmXap4rqhu0yawQ@mail.gmail.com> <878txx4uoq.fsf@handshake.de>

Show all headers | View raw


Daiyue Weng <daiyueweng@gmail.com> writes:
> ...
> I tried to use Cassandra and multiprocessing to insert rows (dummy data)
> concurrently based on the examples in
> ...
> self.pool = Pool(processes=process_count, initializer=self._setup,
> initargs=(session,))
>
> I am wondering how to resolve the issue.

"pickle" is used to serialize Python objects and later, usually in
a different context, recreate the object from the serialization.

Obviously, some objects can be so tightly coupled to the context that
it makes it very difficult to recreate them faithfully. Examples are
locks and files.

Apparently, your framework uses pickle internally (to get objects
from the current processor to the executing processors). As a consequence,
you must ensure that those objects contain only pickleable objects (and
especially no locks).


In your code above, the look might come from "self" or "session".

In the first case, a workaround might be that you put the look
on the class (rather than the object) level; this way, the look would
not be pickled.

The second case would be more difficult. Likely, you would need
to extract pickleable subobjects from your "session" and maybe recreate
a session object from them on the destination processor.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Cassandra multiprocessing can't pickle _thread.lock objects dieter <dieter@handshake.de> - 2016-06-22 08:13 +0200

csiph-web