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


Groups > comp.lang.python > #68441 > unrolled thread

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

Started byChris Angelico <rosuav@gmail.com>
First post2014-03-18 04:40 +1100
Last post2014-03-18 04:40 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromChris Angelico <rosuav@gmail.com>
Date2014-03-18 04:40 +1100
SubjectRe: Thread._stop() behavior changed in Python 3.4
Message-ID<mailman.8208.1395078055.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web