Closed thorstenkampe closed 9 years ago
Don't rely on "running". This is a natural race condition, not a bug.
There is no mentioning neither in your nor the Python documentation that "running" has a race condition. If I cannot rely on "running" then "running" is essentially useless.
I'm not sure how you expected this to work. The "running" state is set by the thread pool executor. It's random which threads gets there first: your call of future.running() or the other thread that sets it.
If I understand you correctly, you're saying that future.running()
returns false
simply because the thread is yet not running. That might be the case but it does not explain the fact that the code snippet I posted is always returning true
with Python3 and always returns false
with your backport. I would expect a backport to be consistent with the original implementation.
And how am I supposed to accomplish that? I hope you understand that the timing is beyond my control.
OS: Windows 8.1, Python 2.7.9 32-bit and 3.4.3 64-bit, also tested under Cygwin and Ubuntu 14.10
The following code snippet will return
False
on Python2 withpythonfutures
andTrue
on Python3 with the builtin module:If you uncomment
print('')
, Python2 withpythonfutures
will printTrue
.