Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #250: Program load too heavy for processor to lift.


comp / comp.lang.python / Re: [Tutor] How to stop a specific thread in Python 2.7?

SubjectAuthor
o Re: [Tutor] How to stop a specific thread in Python 2.7?Cameron Simpson

1
Subject: Re: [Tutor] How to stop a specific thread in Python 2.7?
From: Cameron Simpson
Newsgroups: comp.lang.python
Date: Thu, 3 Oct 2024 23:17 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: [Tutor] How to stop a specific thread in Python 2.7?
Date: Fri, 4 Oct 2024 09:17:19 +1000
Lines: 21
Message-ID: <mailman.35.1727997930.3018.python-list@python.org>
References: <cfjke2jzhnd7tcdnt4cn2a7enhr3ac3at4sxpvajxdgoeb632c@wnsid3oyrax5>
<Zv8l_0Md29OFs_zW@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
X-Trace: news.uni-berlin.de /pPk95+xp6htj1gYw5/37QXwHPzWiCaZgYjJ7aErg6fw==
Cancel-Lock: sha1:Z7o4KUNPNml8TR+m1I5XkNeH1tg= sha256:N64IwXEodhddyXx1bTqvbZnoWlpd1icDuqWAsXcF1Gs=
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'thread':
0.05; "'''": 0.09; 'cc:addr:python-list': 0.09; 'dan': 0.09;
'cheers,': 0.11; 'subject:Python': 0.12; 'cameron': 0.16;
'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net':
0.16; 'none:': 0.16; 'received:13.237': 0.16;
'received:13.237.201': 0.16; 'received:13.237.201.189': 0.16;
'received:cskk.id.au': 0.16; 'received:id.au': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16; 'subject:2.7':
0.16; 'subject:stop': 0.16; 'subject:thread': 0.16; 'wrote:':
0.16; 'cc:addr:python.org': 0.20; 'subject:: [': 0.21; 'subject:]
': 0.21; 'subject:How': 0.23; 'cc:2**0': 0.25; 'header:User-
Agent:1': 0.30; 'subject:Tutor': 0.32; 'header:In-Reply-To:1':
0.34; 'received:au': 0.35; 'target': 0.36; 'those': 0.36;
'shared': 0.39; 'something': 0.40; 'event': 0.40; 'pass': 0.64;
'received:13': 0.64; 'skip:t 20': 0.66; 'received:userid': 0.66;
'interested': 0.68; 'subject:specific': 0.84; 'supplied.': 0.84
Mail-Followup-To: "Dan Ciprus (dciprus)" <dciprus@cisco.com>,
marc nicole via Python-list <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <cfjke2jzhnd7tcdnt4cn2a7enhr3ac3at4sxpvajxdgoeb632c@wnsid3oyrax5>
User-Agent: Mutt/2.2.13 (2024-03-09)
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: <Zv8l_0Md29OFs_zW@cskk.homeip.net>
X-Mailman-Original-References: <cfjke2jzhnd7tcdnt4cn2a7enhr3ac3at4sxpvajxdgoeb632c@wnsid3oyrax5>
View all headers

On 03Oct2024 22:12, Dan Ciprus (dciprus) <dciprus@cisco.com> wrote:
>I'd be interested too :-).

Untested sketch:

def make_thread(target, *a, E=None, **kw):
'''
Make a new Event E and Thread T, pass `[E,*a]` as the target
positional arguments.
A shared preexisting Event may be supplied.
Return a 2-tuple of `(T,E)`.
'''
if E is None:
E = Event()
T = Thread(target=target, args=[E, *a], kwargs=kw)
return T, E

Something along those lines.

Cheers,
Cameron Simpson <cs@cskk.id.au>

1

rocksolid light 0.9.8
clearnet tor