New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix winapi initialization on Python 2.5 on Windows #253
Conversation
except AttributeError: | ||
return id(current_thread()) # Not safe but best we can do | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same try except as on line 33?
Thanks @lndbrg (and sorry for the history clobbering -- wanted the earlier mess out of sight). |
Don't think this will work for all py versions. py3 renamed thread to _thread.
Looks like you need to import threading and check for currentThread or current_thread and then call get_ident on that. |
Updated the above comment. Threading exists on all of the python platforms we try to support. |
Now that's thorough. Thank you again. So, I suppose
would do the trick? |
With the updated matrix I think this would do the trick:
|
The original bug was that |
That's because ident is new in 2.6 on the threading module. But get_ident exists on thread and _thread. something like:
Untested. |
If this is becoming too much of a pain, feel free to punt on it - I mentioned 2.5 in #193 as a matter of course, but once the Python 3 support lands we will discontinue 2.5 support anyway. So this might be moot. Dig if you want - it'd be nice for the last pre-Py3 releases to work well on 2.5 for Windows - but I'm OK to merge #193 without this functioning if it'll save time. EDIT: note that I've only skimmed this so far, recent comments sound like you're still kicking things around? If that's not the case and this can be merge as-is, that's cool too. |
Ignoring py2.5, this looks like the best solution: threading.current_thread().ident |
Well, I flipped the order the identity sources are tried, so now Py2.5 compatibility is the uncommon case. I think this (and #230) would leave the last pre-Py3 version compatible with Win+Py2.5. At least for the agent/winapi bit, anyway... |
This regression (apparently introduced in 1389278) was uncovered during testing #193/#230.
Rudimentary test result below. Doesn't seem to break 2.6/2.7 (though more eyes looking at
get_thread_ident()
might not hurt).