STINNER Victor added the comment:
Eryk:
> We already close the handle in PyThread_start_new_thread() in
> Python/thread_nt.h
Oh right! I completely missed this call. Thanks for double checking the issue
;-) I close the issue as "not a bug".
--
resolution: -> not a bug
stage: -> re
STINNER Victor added the comment:
> [Windows] _thread.start_new_thread() should close the thread handle
So far, I'm not convinced that Python must be changed.
I modified my Python locally so thread_run() writes GetCurrentThread() to
stderr.
Example:
---
SLEEP = 5
import ctypes
import _thre
STINNER Victor added the comment:
> CloseHandle(GetCurrentThread())
This is useless. GetCurrentThread() returns a pseudo handle. The
GetCurrentThread() documentation says:
"The pseudo handle need not be closed when it is no longer needed. Calling the
CloseHandle function with this handle ha
Eryk Sun added the comment:
> Would it be safe to close the handle just after PyThread_start_new_thread()
> success?
We already close the handle in PyThread_start_new_thread() in
Python/thread_nt.h:
if (hThread == 0) {
// ...
}
else {
dprintf(("%lu: PyThread_star
New submission from STINNER Victor :
_thread.start_new_thread() is implemented by calling _beginthreadex().
Currently, when the thread completes: PyThread_exit_thread() is called which
calls "_endthreadex(0)" on Windows. I proposed to no longer call it explicitly
in bpo-44434.
_endthreadex(