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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From dieter <dieter@handshake.de>
Newsgroups comp.lang.python
Subject Re: Cassandra multiprocessing can't pickle _thread.lock objects
Date Wed, 22 Jun 2016 08:13:57 +0200
Lines 33
Message-ID <mailman.27.1466576961.11516.python-list@python.org> (permalink)
References <CAF_EDksR2jqOW9gz1ij2P6XZHq=hEjsftbzmmXap4rqhu0yawQ@mail.gmail.com> <878txx4uoq.fsf@handshake.de>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace news.uni-berlin.de 0tffKD7wTRwCDW/CzUdxSwUGweEfb1JhPW87FnM7pLFA==
Cancel-Lock sha1:kLHqgemUw4tTg8dDoOk/3oGSlHU=
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'context': 0.05; 'concurrently': 0.07; 'internally': 0.09; 'object)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rows': 0.09; 'subject:skip:m 10': 0.09; 'python': 0.10; 'files.': 0.13; '(rather': 0.16; 'consequence,': 0.16; 'data)': 0.16; 'level;': 0.16; 'obviously,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'processor': 0.18; 'issue.': 0.20; 'insert': 0.23; 'second': 0.24; 'tried': 0.24; 'examples': 0.24; 'wondering': 0.25; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'executing': 0.27; 'context,': 0.29; 'locks': 0.29; 'pickle': 0.29; 'workaround': 0.29; 'objects': 0.29; 'code': 0.30; 'especially': 0.32; 'maybe': 0.33; 'class': 0.33; 'usually': 0.33; 'extract': 0.33; 'case,': 0.34; 'skip:i 20': 0.36; '(and': 0.36; 'framework': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us- ascii': 0.37; 'skip:p 20': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'your': 0.60; 'above,': 0.63; 'more': 0.63; 'different': 0.63; 'coupled': 0.84; 'pickleable': 0.84; 'processor.': 0.84
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host p57b388e0.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <878txx4uoq.fsf@handshake.de>
X-Mailman-Original-References <CAF_EDksR2jqOW9gz1ij2P6XZHq=hEjsftbzmmXap4rqhu0yawQ@mail.gmail.com>
Xref csiph.com comp.lang.python:110296

Show key headers only | 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