diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2014-01-21 13:51:09 -0800 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2014-01-21 13:51:09 -0800 |
commit | a7ea04842eb178fa24471914fbaa6d38ec35b78d (patch) | |
tree | 325fc122d6dc38b579f14598ea992fdf88b98895 | |
parent | 2621db122dddc0ade86db22b7b789143db600c8f (diff) |
Clean up thread ident import/exec a bit.
-rw-r--r-- | paramiko/win_pageant.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/paramiko/win_pageant.py b/paramiko/win_pageant.py index 2f6db4f9..d588e81d 100644 --- a/paramiko/win_pageant.py +++ b/paramiko/win_pageant.py @@ -27,11 +27,15 @@ import array import ctypes.wintypes import platform import struct -import thread -import threading + +try: + import _thread as thread # Python 3.x +except ImportError: + import thread # Python 2.5-2.7 from . import _winapi + _AGENT_COPYDATA_ID = 0x804e50ba _AGENT_MAX_MSGLEN = 8192 # Note: The WM_COPYDATA value is pulled from win32con, as a workaround @@ -39,15 +43,6 @@ _AGENT_MAX_MSGLEN = 8192 win32con_WM_COPYDATA = 74 -def get_thread_ident(): - # thread.get_ident() exists from Py2.5 to Py2.7. - # threading.current_thread().ident exists from Py2.6 up to Py3.4. - try: - return threading.current_thread().ident - except AttributeError: - return thread.get_ident() - - def _get_pageant_window_object(): return ctypes.windll.user32.FindWindowA('Pageant', 'Pageant') @@ -88,7 +83,7 @@ def _query_pageant(msg): return None # create a name for the mmap - map_name = 'PageantRequest%08x' % get_thread_ident() + map_name = 'PageantRequest%08x' % thread.get_ident() pymap = _winapi.MemoryMap(map_name, _AGENT_MAX_MSGLEN, _winapi.get_security_attributes_for_user(), |