Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

But what can you do with it? -- ubiquitous cry from Linux-user partner


devel / comp.lang.python / Re: Python child process in while True loop blocks parent

SubjectAuthor
o Re: Python child process in while True loop blocks parentChris Angelico

1
Re: Python child process in while True loop blocks parent

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Python child process in while True loop blocks parent
Date: Tue, 7 Dec 2021 05:27:43 +1100
Lines: 32
Message-ID: <mailman.21.1638815275.15287.python-list@python.org>
References: <MphOu5i--3-2@tutanota.com>
<B05343F2-30B5-470C-8CFC-EBFA7C5EFD6A@barrys-emacs.org>
<MphoqOf--3-2@tutanota.com>
<7A3CE5EB-C53A-404D-BF32-77CF0243BF3D@barrys-emacs.org>
<MpqihHm--3-2@tutanota.com>
<27742189-51F0-49A8-ACA7-344EFCD2B1BD@barrys-emacs.org>
<MqAitZV--3-2@tutanota.com>
<0633A53B-A722-4CEE-8F20-E2D0AEBB8D01@barrys-emacs.org>
<MqC-YXO--B-2@tutanota.com> <20211206020831.ytkglawzaeoueyhh@hjp.at>
<MqFiCj---3-2@tutanota.com>
<CAPTjJmqS+UE_-PPaz=1eS-juAAM2DgxXWY6wvEp3WJqsb8ErxA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 1BgTkJCOxCZ2wk/mO3obsg9E+9CtnFPFMdEbxYV12Vpg==
Return-Path: <rosuav@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=qMFIJ/pA;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'thread': 0.05; 'clarify':
0.07; 'cpu': 0.07; 'parent': 0.07; 'child': 0.09; 'fork': 0.09;
'linux': 0.09; 'obviously': 0.09; 'threads': 0.09; 'ubuntu': 0.09;
'subject:Python': 0.12; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'instance': 0.16; 'owns': 0.16;
'resources,': 0.16; 'rough': 0.16; 'subject:True': 0.16;
'subject:child': 0.16; 'subject:loop': 0.16; 'subject:parent':
0.16; 'subject:while': 0.16; 'thread.': 0.16; 'wrote:': 0.16;
'code.': 0.17; "can't": 0.17; 'tue,': 0.19; 'to:addr:python-list':
0.20; 'bit.': 0.22; 'creates': 0.22; 'maybe': 0.22; "what's":
0.22; 'run': 0.23; 'it,': 0.29; 'code,': 0.31; 'comment': 0.31;
'dec': 0.31; "doesn't": 0.32; 'here,': 0.32; 'python-list': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'core': 0.34;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'running': 0.34; '"the': 0.35; 'runs': 0.35;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37;
'received:209': 0.39; 'single': 0.39; 'explain': 0.40; 'helps':
0.60; "there's": 0.61; 'between': 0.63; 'capable': 0.64;
'definition': 0.64; 'your': 0.64; 'url-ip:45/8': 0.65; 'digital':
0.65; 'exactly': 0.68; 'ocean': 0.69; 'performance,': 0.69;
'2021': 0.71; 'skip:* 10': 0.71; 'man': 0.74; 'out.': 0.80;
'(other': 0.84; 'stating': 0.84; 'switching': 0.84; "that'll":
0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:content-transfer-encoding;
bh=yepJj/2QnuuQKTVEtQ+zzvw4ETh6KZeiYEUpgUrpvmA=;
b=qMFIJ/pAoqnn87yoEuxtbkT6/zSElln8YlpGraBgGTQYRwXpW4gx4XdiWVWO8Zdr/W
h/mYGcxT2eN3Yt016B38o2mWgIAhZ8MUoXrvksqMNMeA1Y/AKm4H3hBUjuyTYy4KS9dC
vTNCGktFNHLsq7MWIMs6zV4VXZ3j0Zxnn96KKq2ho/T+HjhJPxv6FifXEIalVdg0HfLY
v5CrLPnWfsFUjiKzuhTAX33LzVjkdAKQMCMv8BEBIbzDEKasvGK5+oPNtWF/yTNnyUg8
0hmhiJJ1uoVLplTpd1SuDjI41v0pX0O50soOKrxil8LBi+YS2f9IVGlHSJSP3SeNH6GU
mNRg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-transfer-encoding;
bh=yepJj/2QnuuQKTVEtQ+zzvw4ETh6KZeiYEUpgUrpvmA=;
b=y9tcyn1/SRyUyWHvcjijh92Qy6WQuAHA0EYCo0RlynZ2yqrjF6VdK1UU7j3LA+Dsmd
rTPosjoUSu4UxIQ3WHFVUooG1lB080UIDtiahol+OQBIpeytlPVxD1Zgdnis6dU2ZYRN
N+bgPzrcv6y6ToZbzHmao3f3QzbJMeWyWjkraltB91dqn+sQujlUgR6dY1cWxeVeJ73g
qgtuCTi/5xyI0Ihv+mcCUGiXV8JrX1lKmu6/YsD6OQB111WQZu+ucA1p3eOKNL4p9cV+
wFFiG4hxeTiu//endWpJKJ8BN645bN1WNh1HwTiUmPEW8WRhJ2iOUV45OE/HYuCwE21G
+ucg==
X-Gm-Message-State: AOAM530EFACzCMWnC0IOZZCvUPzUEvO1lhyl5qEWAaCjQ+ff75TEtU/F
tpl0XEbhsTjzC9H5mFxjAaHNkCAkw9fWqchBjZ2hB0oR
X-Google-Smtp-Source: ABdhPJys2Pz2nMo1EdnXyCj/N11g0uXFIcH9sDNgwcW+K4/nE/7KJh/Yg3323BVkyCLGKNKindLjfhn4H6ycJx7iKIs=
X-Received: by 2002:adf:b18e:: with SMTP id q14mr47671499wra.477.1638815274050;
Mon, 06 Dec 2021 10:27:54 -0800 (PST)
In-Reply-To: <MqFiCj---3-2@tutanota.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.38
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: <CAPTjJmqS+UE_-PPaz=1eS-juAAM2DgxXWY6wvEp3WJqsb8ErxA@mail.gmail.com>
X-Mailman-Original-References: <MphOu5i--3-2@tutanota.com>
<B05343F2-30B5-470C-8CFC-EBFA7C5EFD6A@barrys-emacs.org>
<MphoqOf--3-2@tutanota.com>
<7A3CE5EB-C53A-404D-BF32-77CF0243BF3D@barrys-emacs.org>
<MpqihHm--3-2@tutanota.com>
<27742189-51F0-49A8-ACA7-344EFCD2B1BD@barrys-emacs.org>
<MqAitZV--3-2@tutanota.com>
<0633A53B-A722-4CEE-8F20-E2D0AEBB8D01@barrys-emacs.org>
<MqC-YXO--B-2@tutanota.com> <20211206020831.ytkglawzaeoueyhh@hjp.at>
<MqFiCj---3-2@tutanota.com>
 by: Chris Angelico - Mon, 6 Dec 2021 18:27 UTC

On Tue, Dec 7, 2021 at 4:10 AM Jen Kris via Python-list
<python-list@python.org> wrote:
>
> I can't find any support for your comment that "Fork creates a new
> process and therefore also a new thread." From the Linux man pages https://www.man7.org/linux/man-pages/man2/fork.2.html, "The child process is created with a single thread—the one that called fork()."
>
> I have a one-core one-thread instance at Digital Ocean available running Ubuntu 18.04. I can fork and create a new process on it, but it doesn't create a new thread because it doesn't have one available.
>

A CPU core is capable of running one or more threads *concurrently*,
and having multiple cores obviously multiplies that out. But for what
you're doing here, there's no material difference between threads
running concurrently and threads switching out between themselves
(other than performance, of course). From the operating system and
application perspectives, a "thread" is one runnable thread.

Every Unix process must contain a minimum of one thread. As a rough
rule of thumb, a process owns resources, a thread runs code. Without a
thread, you can't run any code.

Forking a process creates a child process and leaves the parent
running. The child process must by definition have a minimum of one
thread, and the man page is stating that one thread is all it gets.

Hope that helps explain things a bit. I don't know exactly what's
going on in your code, but maybe that'll clarify the word "thread".

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor