Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It's always sad when the fleas leave, because that means your dog is dead. -- Wesley T. Williams


devel / comp.lang.python / Re: Execute in a multiprocessing child dynamic code loaded by the parent process

SubjectAuthor
o Re: Execute in a multiprocessing child dynamic code loaded by theMartin Di Paola

1
Re: Execute in a multiprocessing child dynamic code loaded by the parent process

<mailman.231.1646659972.2329.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17421&group=comp.lang.python#17421

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: martinp....@gmail.com (Martin Di Paola)
Newsgroups: comp.lang.python
Subject: Re: Execute in a multiprocessing child dynamic code loaded by the
parent process
Date: Mon, 7 Mar 2022 13:32:44 +0000
Lines: 43
Message-ID: <mailman.231.1646659972.2329.python-list@python.org>
References: <20220307023017.qjcqbn7znoour6rm@gmail.com>
<7E685F22-DEA2-431B-ACDC-7FB0AC933B01@barrys-emacs.org>
<20220307133244.l46ficx6ebtytpdj@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de sz2Vmb681EIA0glXDDGfLwGAc7fGV+L1ljERXnS0HBiA==
Return-Path: <martinp.dipaola@gmail.com>
X-Original-To: Python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=jd6Cu1ub;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.017
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '(which': 0.04; '2022':
0.05; 'mar': 0.07; '*not*': 0.09; 'code?': 0.09; 'module.': 0.09;
'import': 0.15; 'that.': 0.15; '2022,': 0.16; 'barry': 0.16;
'importing': 0.16; 'pickle': 0.16; 'subject:child': 0.16;
'subject:code': 0.16; 'subject:dynamic': 0.16; 'subject:parent':
0.16; 'subject:skip:m 10': 0.16; 'wrote:': 0.16; 'python': 0.16;
'message-id:@gmail.com': 0.18; 'to:addr:python-list': 0.20;
'code': 0.23; 'run': 0.23; 'module': 0.31; 'think': 0.32; 'but':
0.32; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'yes,': 0.35; 'from:addr:gmail.com': 0.35; 'mon,': 0.36; "skip:'
10": 0.37; 'received:209.85': 0.37; 'received:209': 0.39;
'necessary': 0.39; 'martin': 0.40; 'true': 0.63; 'skip:m 20':
0.63; 'check.': 0.64; 'following:': 0.69; 'plus': 0.73; 'yes':
0.76; 'quick': 0.77; '(like': 0.84; 'imports': 0.84; 'martin.':
0.84; 'paola': 0.84; 'received:209.85.161': 0.84; 'skip:p 50':
0.84; 'subject: \n ': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=date:from:to:subject:message-id:mail-followup-to:'user-agent
:references:mime-version:content-disposition:in-reply-to;
bh=9zz0r5QfLgP7HaEa89SYCZeTzWq1DnYu5DdWRXB8Qac=;
b=jd6Cu1ubrJMOOt6GIk+rd9fkoAo0F6B7Tx/Mfxnuyc9ecNJk+RAiMprcIR2Wnq9wcX
dv5dowUpV4VudlrL7u5mH5sB582sbPuDekqaR/H7+Ul6fyU2U3n1GdNv1UPCaD+86SNj
bw9csXN7TF1Ck7f7IJvi6JJ+MzvYwvPBEvs3TOzcBryjV48Q0jv+VNq9mmWK5OhBifyF
GZ3VKUWXPu446QL57jGfhF3ol8j8NdtqJhr6X4nzeZSqfDEx8dbWtZY5rxRFeJl3eS95
z+EnAy7HGQ8LQCJ0mIvSkSok98GKOUTJ/+9FzzGOcaITJ4Qx+q9AwmmWCHqECo0N/Psk
6qMg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to
:'user-agent:references:mime-version:content-disposition:in-reply-to;
bh=9zz0r5QfLgP7HaEa89SYCZeTzWq1DnYu5DdWRXB8Qac=;
b=mgmuy8UcWh3gZWyzHP6XDeUgREd8RvgQJxajP8moMmaC961QXWVoFINYiciNpcXB7J
sc7oiEeO3qGz4n/pW+xbVWRAsQFn1BeKZJazw+qFztcREhx7oPc+Td/wYvuDP9rCcgrs
u7qKP3igXNCVIL5OgUzY37GWsfCklIEQJCgEuV6XIwRpyY2OXamptd3O80blUJz4gCoN
snt99ILpnlPGunufLibLGZNzihVdS6DmRRg2fO7CnIB1o/WvlzWg6uD63lVZTWkZaCVJ
r+12fubvUMNqsQRxG8KZRpMTi3R8URDQC8lza9yHpI/aMQOUP0WXMxVer+yjJKCE+D/Z
Zw8w==
X-Gm-Message-State: AOAM533ggEbMGFhw4A/pG7KQzbOIVcapvQHZFi/JCtrpMTy/sBgM3ZmC
nmOD+pP4qLwMqQc3/w52oqsfrQ76zbs=
X-Google-Smtp-Source: ABdhPJzljxZaR455WxCXdD0o5E8S+a/ENbIOpdaa96R4j+wSoxYLA4eWFxcfmVvwwaX0OUjWIbX4Wg==
X-Received: by 2002:a05:6870:ee1b:b0:d7:5c8b:4fcf with SMTP id
ga27-20020a056870ee1b00b000d75c8b4fcfmr14418890oab.52.1646659969610;
Mon, 07 Mar 2022 05:32:49 -0800 (PST)
Mail-Followup-To: Python-list@python.org
'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101
Thunderbird/52.5.2 Lightning/5.4.5.2'
Content-Disposition: inline
In-Reply-To: <7E685F22-DEA2-431B-ACDC-7FB0AC933B01@barrys-emacs.org>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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: <20220307133244.l46ficx6ebtytpdj@gmail.com>
X-Mailman-Original-References: <20220307023017.qjcqbn7znoour6rm@gmail.com>
<7E685F22-DEA2-431B-ACDC-7FB0AC933B01@barrys-emacs.org>
 by: Martin Di Paola - Mon, 7 Mar 2022 13:32 UTC

I understand that yes, pickle.loads() imports any necessary module but
only if they can be find in sys.path (like in any "import" statement).

Dynamic code loaded from a plugin (which we presume it is *not* in
sys.path) will not be loaded.

Quick check. Run in one console the following:

import multiprocessing
import multiprocessing.reduction

import pickle
pickle.dumps(multiprocessing.reduction.ForkingPickler)
<copy the output>

In a separated Python console run the following:

import pickle
import sys

'multiprocessing' in sys.modules
False

pickle.loads(<paste the dump here>)

'multiprocessing' in sys.modules
True

So the last check proves that pickle.loads imports any necessary module.

Martin.

On Mon, Mar 07, 2022 at 08:28:15AM +0000, Barry wrote:
>
>
>> On 7 Mar 2022, at 02:33, Martin Di Paola <martinp.dipaola@gmail.com> wrote:
>>
>> Yes but I think that unpickle (pickle.loads()) does that plus
>> importing any module needed
>
>Are you sure that unpickle will import code? I thought it did not do that.
>
>Barry

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor