Deutsch English Français Italiano |
<mailman.9.1727297834.2990.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail From: marc nicole <mk1853387@gmail.com> Newsgroups: comp.lang.python Subject: Re: How to stop a specific thread in Python 2.7? Date: Wed, 25 Sep 2024 22:56:58 +0200 Lines: 31 Message-ID: <mailman.9.1727297834.2990.python-list@python.org> References: <CAGJtH9RBmcofpg5ifiXZm4z8XRBQkGVzDSduR7=9QH75-Ubpgw@mail.gmail.com> <ZvR2GbgY9Xs33hNm@cskk.homeip.net> <CAGJtH9QwwYDRcqkM7Vtgy_ZraOZbrCcsyGODveNPFtpT7+L_6g@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: news.uni-berlin.de 2tSEIaJDyWIMF/Ms58Ok/gc8YPJyd9NJvoT3pISeuySA== Cancel-Lock: sha1:UtmsYhNecE0gln3Lg27NdWVJEcU= sha256:/MegphmRKsKhnkoFbUN0ij4FVuty0gpV9XmnxYb0TV8= 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=WziZrC4f; dkim-adsp=pass; dkim-atps=neutral X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'thread': 0.05; 'email addr:python.org>': 0.09; 'set.': 0.09; 'cheers,': 0.11; 'subject:Python': 0.12; '>': 0.14; 'url:mailman': 0.15; 'cameron': 0.16; 'sept': 0.16; 'simpson': 0.16; 'skip:> 10': 0.16; 'skip:> 20': 0.16; 'subject:2.7': 0.16; 'subject:stop': 0.16; 'subject:thread': 0.16; 'wrote:': 0.16; 'python': 0.16; 'instead': 0.17; 'to:addr:python-list': 0.20; 'to:no real name:2**1': 0.22; 'subject:How': 0.23; 'run': 0.23; 'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'url- ip:188.166/16': 0.25; 'email addr:python.org>': 0.28; 'url- ip:188/8': 0.31; "doesn't": 0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34; 'running': 0.34; 'from:addr:gmail.com': 0.35; 'single': 0.39; 'wed,': 0.39; 'want': 0.40; 'event': 0.40; 'becomes': 0.64; 'well': 0.65; 'skip:t 20': 0.66; 'following:': 0.69; 'email name:<python-list': 0.84; 'id)': 0.84; 'subject:specific': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727297831; x=1727902631; darn=python.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=V91awgvODCKdHiSyS+t6aTs1eSRGHPC9YFGZUmfA8mY=; b=WziZrC4fq0ZOVjeKy6M8Fxgw08SDKadF0x1p2n0u61ynpsLSA+K8E7llWXaTCU9tyu +s95ivMJ0EsMPf2tv6fAQybtBlvu2wAkRdw1NAYNkrvyJre4Kx65zdeLh4yzlVHac9L1 Bp/mWQxBKdfqw7xtqBupC/ZXXeotmvoSdRoQtmLMRQnqbN6jz+wDMnhPOomBZts+zP9F kFR+JoZnwTDPBBEcYmJ5IEP8/yuoXpweqfCI/zxERjH0KpTD2W4Lh23gvq4j50WXYycr 2h5lN7wNKNFyJP3hg2yVHjXNXitOyTwnXgoReGGEunDJekcViObPJVeMzgjNAhhf9/VK dGYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727297831; x=1727902631; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V91awgvODCKdHiSyS+t6aTs1eSRGHPC9YFGZUmfA8mY=; b=KAqzHnrhUuvHTYfBxYxV5P0KLFMGl47Qc5zzwaIPlbEALUV09Ye18cRweWVuB9Gj4G ZM6xlX0I3iz8C2ysmyLaezfgry6/DicpXT5vh0ia+Ng5ksrgptTa9wnLcZfRgJ4jcz6a 5yh9huWJCfK+qOa6G2xjnmJaPYJgEfxl70qm48VqApLpocgPx5HUf+qilLunVDUEHJw+ COvX3/QmtgBKs1PleYva4mVfkshp+pYFhLAt8iEzAvfzFoiDK4NvC94bTOkRz4pxDOl7 YWFPHKErUU16Gs6BR63d+SUIHnY8CksTBMUcRZsVWQqYqgiuB3czEPZoyz1SAE9NajAR +ouA== X-Forwarded-Encrypted: i=1; AJvYcCWyWxeXuB4AuCBulEs73DuNl/Rv59rx8Ryk+0fXZnnPx0FKdYqTwjSwO4yJGxoWIyzIUmw5+omhkMt6ZBA=@python.org, AJvYcCX+5TfiwRVpsgnMnrIzv0Yf/x5qbfDaag9Ou+9Pup/5inBdUm5RPnUEuQkOOkUF2ZbX+pjlxw==@python.org X-Gm-Message-State: AOJu0YwPL4ugxHXbI/jCDwUHOBNrY/S+Da6wMnP/2CQkKHUmVjLj3Xo6 e+pY/b2SVuSQRe9UQ6YRahi1sm8xlosw86Zot+lu+ylijxwPJ6kyby4qcyhCFmGHIXb3z8VIseZ nFhraBD20WakjLPd4cpDl0+MJdgs= X-Google-Smtp-Source: AGHT+IEaEtL1SY/U1FCOid3Jesu2kbpyQDTemYa5Xq20xQ8Nrfi/2jT842H2qRcDYYWnDuoeEjxLdgKcLjlZrGoF/CU= X-Received: by 2002:a05:690c:4281:b0:6e2:2c72:3aaf with SMTP id 00721157ae682-6e22c723c53mr16433237b3.31.1727297830400; Wed, 25 Sep 2024 13:57:10 -0700 (PDT) In-Reply-To: <ZvR2GbgY9Xs33hNm@cskk.homeip.net> 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: <CAGJtH9QwwYDRcqkM7Vtgy_ZraOZbrCcsyGODveNPFtpT7+L_6g@mail.gmail.com> X-Mailman-Original-References: <CAGJtH9RBmcofpg5ifiXZm4z8XRBQkGVzDSduR7=9QH75-Ubpgw@mail.gmail.com> <ZvR2GbgY9Xs33hNm@cskk.homeip.net> Bytes: 6225 How to create a per-thread event in Python 2.7? On Wed, 25 Sept 2024, 22:47 Cameron Simpson via Python-list, < python-list@python.org> wrote: > On 25Sep2024 19:24, marc nicole <mk1853387@gmail.com> wrote: > >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? > > No, `set()` doesn't kill a thread at all. It sets the `Event`, and each > thread must be checking that event regularly, and quitting if it becomes > set. > > You just need a per-thred vent instead of a single Event for all the > threads. > > Cheers, > Cameron Simpson <cs@cskk.id.au> > -- > https://mail.python.org/mailman/listinfo/python-list >