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


Groups > comp.lang.python > #6920

Re: Multiprocessing.connection magic

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'something,': 0.07; 'pm,': 0.10; '>>>': 0.12; 'def': 0.12; 'received:209.85.214.174': 0.14; 'received:mail-iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'angelico': 0.16; 'encode': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'len(x)': 0.16; 'odd,': 0.16; 'shutil': 0.16; 'importing': 0.19; 'header:In-Reply-To:1': 0.21; 'seems': 0.21; 'fri,': 0.23; "doesn't": 0.25; 'tried': 0.27; 'work.': 0.28; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'discard': 0.29; 'gather': 0.29; 'work:': 0.29; 'code,': 0.29; 'skip:b 30': 0.31; "didn't": 0.31; 'to:addr:python-list': 0.33; 'actually': 0.33; 'chris': 0.34; 'received:google.com': 0.37; 'received:209.85': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'explain': 0.39; 'received:209': 0.39; 'attempt': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'original,': 0.84; 'subject:magic': 0.84; 'subject:skip:M 20': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=bi40bq2xVLtCLEZc44i1disxLOTteL83EcHZPFTjfkU=; b=UafMGoaWyvmBR/jLegIMYg1V/2G2pEjM2T6LOMpWx98O3shlF2g5IwLGmO+hOcE17i dDjkojM2kPU9u7p3WAjYwqjFX48TD5MFD3TrrPNwdXzdxziVURr4l9onigScSTq/8UxU NgsubC5VCD9dLphZZykMgsmhoRefgEUuJTW9A=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=iynV+c4s9YToZRl5eIgarTQpOXGHLfGthiYK0npl4bAXpObUc9UEfvYWih0eJyPyxV ns0PRrovZrstUlVxEX603LL7WXoHyR/wIKyeJjUeDFqudOrC0m9tRllE8aUpozsmuA6i tdGcjT6OXDBfw+j8FEaIz6hExd4WNYUTYddVs=
MIME-Version 1.0
In-Reply-To <isa10n02ifb@news3.newsguy.com>
References <mailman.2417.1307082948.9059.python-list@python.org> <isa10n02ifb@news3.newsguy.com>
Date Fri, 3 Jun 2011 17:18:43 +1000
Subject Re: Multiprocessing.connection magic
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2419.1307085526.9059.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 82.94.164.166
X-Trace 1307085526 news.xs4all.nl 49181 [::ffff:82.94.164.166]:46353
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6920

Show key headers only | View raw


On Fri, Jun 3, 2011 at 5:03 PM, Chris Torek <nospam@torek.net> wrote:
> The real magic is in the unpickler, which has figured out how to
> access shutil.copy without importing shutil into the global namespace:

So from this I gather that it doesn't actually pickle the code, just
the name. Seems a little odd, but that would explain why this didn't
really work:

>>> def asdf(x):
	x.append(len(x))
	return len(x)

>>> pickle.dumps(asdf)
b'\x80\x03c__main__\nasdf\nq\x00.'
>>> asdf=pickle.dumps(asdf)
>>> pickle.loads(asdf)
b'\x80\x03c__main__\nasdf\nq\x00.'
>>> asdf
b'\x80\x03c__main__\nasdf\nq\x00.'

I tried to do the classic - encode something, discard the original,
attempt to decode. Didn't work.

Chris Angelico

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


Thread

Multiprocessing.connection magic Claudiu Popa <cpopa@bitdefender.com> - 2011-06-03 09:28 +0300
  Re: Multiprocessing.connection magic Chris Torek <nospam@torek.net> - 2011-06-03 07:03 +0000
    Re: Multiprocessing.connection magic Chris Angelico <rosuav@gmail.com> - 2011-06-03 17:18 +1000
  Re: Multiprocessing.connection magic Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-06-03 10:03 +0200
    Re: Multiprocessing.connection magic Chris Angelico <rosuav@gmail.com> - 2011-06-03 18:26 +1000
      Re: Multiprocessing.connection magic Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-03 08:50 +0000
        Re: Multiprocessing.connection magic Chris Angelico <rosuav@gmail.com> - 2011-06-03 20:34 +1000

csiph-web