Deutsch   English   Français   Italiano  
<mailman.7.1727285081.2990.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.roellig-ltd.de!open-news-network.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: marc nicole <mk1853387@gmail.com>
Newsgroups: comp.lang.python
Subject: How to stop a specific thread in Python 2.7?
Date: Wed, 25 Sep 2024 19:24:49 +0200
Lines: 16
Message-ID: <mailman.7.1727285081.2990.python-list@python.org>
References: <CAGJtH9RBmcofpg5ifiXZm4z8XRBQkGVzDSduR7=9QH75-Ubpgw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de WuGaciXb0rBC/Not9/Hm+wM/mUlREf//rqPGjeG/xGLw==
Cancel-Lock: sha1:D3EWq6Tyku2uZWcA1ny589r5gYY= sha256:3dI6d1cvZDOoRDNmxSVTgJVdFXm8Bdw2houu3aXZrAk=
Return-Path: <mk1853387@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=VjjXpayO;
 dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.046
X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'thread': 0.05; 'guys,':
 0.09; 'subject:Python': 0.12; 'subject:2.7': 0.16; 'subject:stop':
 0.16; 'subject:thread': 0.16; 'to:addr:python-list': 0.20; 'to:no
 real name:2**1': 0.22; 'subject:How': 0.23; 'run': 0.23;
 'thanks!': 0.24; 'sfxlen:2': 0.31; 'message-id:@mail.gmail.com':
 0.32; 'but': 0.32; 'there': 0.33; 'received:google.com': 0.34;
 'running': 0.34; 'from:addr:gmail.com': 0.35; 'want': 0.40;
 'well': 0.65; 'skip:t 20': 0.66; 'following:': 0.69; 'id)': 0.84;
 'subject:specific': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1727285078; x=1727889878; darn=python.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=agPmndtBjb1STkxD/IW21k6CTBaFKa0SX9ihmaECSPs=;
 b=VjjXpayOmHU9QLvogHgFQsQ6K0qsfvw3F0yM6/RBVxQVEe5gA3nxfiueCzPPcusygh
 jV1BIT+7evSanDSJ1dD18mqBvwT7PgHxU5J0eafHXUB27Q/nEV4jXBOZG77vJ6UJzY0X
 +W23Qf0CiCZTqJGcHbnTdZbzzdw9XUwZsiNj7chqne0XoK+V/i8y0heZHs4Z3GQjxUhW
 1ElYEDY4K46ht6TH6u4vKCAwJLotFJHuLQ5K36EKJi7yNMOsUi3rJidmkAASLcfP8zoV
 F9a8chnOmNQ2g7nwrp4BbWatMVLWq/RIcJnaEhspfgTOIzuXme93Bmyy79urWSoDaDJ8
 lc9g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1727285078; x=1727889878;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=agPmndtBjb1STkxD/IW21k6CTBaFKa0SX9ihmaECSPs=;
 b=cQVyldIEHgTlAutH1cfoGdtMTCv4CmWfTqXK0rvW+omY5CWSbLQdQsBoLBFmD/PrJk
 XXBI3NM6/MRLumTbfKb2q2L7oPkibgt3p1gRef/37B+moyaloqzM3nLygMocc+F1jPnT
 elIdlSQ3lJsvStY7AnmRau5vZcWMXSQ6BVM1br4vTnU+Cn4x9R+5HW6n+XoqOSDmflr9
 S8EoJN/ZaV97+0LYJo3t0F36LxYj7oGu/Y3nUeRi9ww7vgP0lw7dxuHlQPlo+E+0t2V4
 lbefVPzhyjiHKFthkinKSR8aD75AVQOTj3tbpoa/6MsdAFrVApmKvvampoDieYZm65TZ
 RDXA==
X-Forwarded-Encrypted: i=1;
 AJvYcCVICTQUm4vGZUXWxSlNq1fOc0QcxkALc/Ds1BoRdWm+S/rulee/VPOjWs1m++CE6JwlnkB2KtE1uezvKA==@python.org
X-Gm-Message-State: AOJu0Yzq9QPmHKJe+HiGz5uVbjGisnJ7X6/WTayXI/81/y0edokuTgBX
 s1W34SkC9mEmsYM2yiOiVNix/PhB5vuGk425UgvQha1CYEyWloEsBYNaWdgS0VHuGqsOVY6ZaS3
 P2yayi8fDa3h9qT6/KBnMFnnjSFPeGwhx
X-Google-Smtp-Source: AGHT+IH2bhCPkwalO+I08c+qx3FW/FHwWZx4wuWGVhdsJKtiGfi3wcyqwrtzENYNgwgp0NSdwO6eRSfAcIoRXMggL9Q=
X-Received: by 2002:a05:690c:d8b:b0:6b0:e813:753b with SMTP id
 00721157ae682-6e21d9f10c0mr36884497b3.38.1727285078196; Wed, 25 Sep 2024
 10:24:38 -0700 (PDT)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CAGJtH9RBmcofpg5ifiXZm4z8XRBQkGVzDSduR7=9QH75-Ubpgw@mail.gmail.com>
Bytes: 4728

Hello guys,

I want to know how to kill a specific running thread (say by its id)

for now I run and kill a thread like the following:
# start thread
thread1 = threading.Thread(target= self.some_func(), args=( ...,), )
thread1.start()
# kill the thread
event_thread1 = threading.Event()
event_thread1.set()

I know that set() will kill all running threads, but if there was thread2
as well and I want to kill only thread1?

Thanks!