Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68441

Re: Thread._stop() behavior changed in Python 3.4

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'broken': 0.04; 'subject:Python': 0.06; 'practice,': 0.07; 'versions.': 0.07; 'indication': 0.09; 'underscore': 0.09; 'url:github': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'bug': 0.12; 'thread': 0.14; 'antoine': 0.16; 'be:': 0.16; 'broken.': 0.16; 'cc:name:python list': 0.16; 'doubly': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'highlighted': 0.16; 'itself,': 0.16; 'undocumented': 0.16; 'url:pydev': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'trying': 0.19; 'cc:addr:python.org': 0.22; "shouldn't": 0.24; 'stopping': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'wonder': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; 'says': 0.33; 'url:python': 0.33; 'noticed': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'method': 0.36; 'should': 0.36; 'bad': 0.39; 'according': 0.40; 'even': 0.60; 'easy': 0.60; 'reaching': 0.61; 'simply': 0.61; "you're": 0.61; 'places': 0.64; 'different': 0.65; 'mar': 0.68; 'obvious': 0.74; 'behavior': 0.77; '3.4': 0.84; 'fail.': 0.84; 'url:master': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=3JRcTxTCsB+524EDbzw5dPM8Z/ztnuyWlXRnHWr9K4o=; b=hXax1mrzakwGpXRVNoScJ6V0G429ow9U+nJUDdwU2c7N4xOkiTy7kdi7U2wwZ2Rpgt Dxd6hfmsiKcg5xriIln+GnT/X0sh4TT5W3pelwcryNp4jjUaZm1+tzTTw6U0CwaKveB2 LsKdAsR+WBurxi5tKlNgmWsJ43kXLhyxB2EnEB1v+fa3jsHV51Y9AfTZPVq4I4pT5osm jMkoz/EmZy8TaHVK7YoPR8KneuC+TNTybF0hfqcSdY6u3X/7pzKXkvEPhJv6kk6wSADm PUjLFbg8pw3UO6fuXTtXC4mMVRzNRRjihX5pSi5l8j2zXUZd0LvLwlvqxLv7JKE/wuxD 6LGA==
MIME-Version 1.0
X-Received by 10.66.11.66 with SMTP id o2mr4849125pab.142.1395078051422; Mon, 17 Mar 2014 10:40:51 -0700 (PDT)
In-Reply-To <279038900.uDlbjECTej@felix-arch>
References <279038900.uDlbjECTej@felix-arch>
Date Tue, 18 Mar 2014 04:40:51 +1100
Subject Re: Thread._stop() behavior changed in Python 3.4
From Chris Angelico <rosuav@gmail.com>
Cc Python List <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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 <http://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>
Newsgroups comp.lang.python
Message-ID <mailman.8208.1395078055.18130.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395078055 news.xs4all.nl 2835 [2001:888:2000:d::a6]:54945
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68441

Show key headers only | View raw


On Tue, Mar 18, 2014 at 4:18 AM, Felix Yan <felixonmars@gmail.com> wrote:
> I noticed a behavior change on Thread._stop() with Python 3.4.
>
> I know the method is an undocumented "feature" itself, but some projects are
> using it, and now they fail.
>
> I know trying to forcefully stop a thread is not really a good practice, but I
> still wonder if there's an easy way to get broken programs to work again, just
> in the way they currently are?

You're using something that has a leading underscore on the name.
Frankly, you shouldn't be doing that. Your code was already broken,
before 3.4 came along, and it's just that 3.4 highlighted that
brokenness. The PyCharm report that this is a Python 3.4 bug is simply
incorrect. This code should be a strong indication that something's
reaching into places it shouldn't be:

https://github.com/JetBrains/intellij-community/blob/master/python/helpers/pydev/pydevd_comm.py#L109

The solution is to have the thread acknowledge, in some way, that it
needs to shut down. Forcefully stopping a thread is actually a really
bad practice, at least in Python (with OS/2 and VX-REXX, it's a
different matter). Antoine says that this doesn't even stop the thread
(I can't say; I've never used _stop(), for obvious reasons), so this
code was doubly broken. The change in 3.4 should be an excuse to fix
the code so it actually works, and works according to the spec, which
will mean it works on all versions.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Thread._stop() behavior changed in Python 3.4 Chris Angelico <rosuav@gmail.com> - 2014-03-18 04:40 +1100

csiph-web