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


Groups > comp.lang.python > #68437

Thread._stop() behavior changed in Python 3.4

From Felix Yan <felixonmars@gmail.com>
Subject Thread._stop() behavior changed in Python 3.4
Date 2014-03-18 01:18 +0800
Newsgroups comp.lang.python
Message-ID <mailman.8204.1395076687.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi list,

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.

A minimized snippet to reproduce:

#!/usr/bin/python
import threading
def stale():
    import time
    time.sleep(1000)
t = threading.Thread(target=stale)
t.start()
t._stop()

This works correctly with Python 3.3, the program exits immediately after 
t._stop() called, and no exception was raised.

But with Python 3.4, an AssertionError was raised:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    t._stop()
  File "/usr/lib/python3.4/threading.py", line 990, in _stop
    assert not lock.locked()
AssertionError

And the program still waits on the sleep().

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?

Downstream bug reports, for reference:

http://youtrack.jetbrains.com/issue/PY-12317
https://github.com/paramiko/paramiko/issues/286

Regards,
Felix Yan

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


Thread

Thread._stop() behavior changed in Python 3.4 Felix Yan <felixonmars@gmail.com> - 2014-03-18 01:18 +0800

csiph-web