From b9437316b441f732ad56309e7d908d2799d2a646 Mon Sep 17 00:00:00 2001 From: kamgha Date: Sat, 26 Aug 2017 03:54:29 +0200 Subject: [PATCH] Add snake-case function names for 'threading2'-module Closes: #165 --- direct/src/stdpy/threading2.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/direct/src/stdpy/threading2.py b/direct/src/stdpy/threading2.py index 9beee770c0..d041faaa2b 100644 --- a/direct/src/stdpy/threading2.py +++ b/direct/src/stdpy/threading2.py @@ -24,9 +24,18 @@ from time import time as _time from traceback import format_exc as _format_exc # Rename some stuff so "from threading import *" is safe -__all__ = ['activeCount', 'Condition', 'currentThread', 'enumerate', 'Event', - 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', - 'Timer', 'setprofile', 'settrace', 'local', 'stack_size'] +__all__ = [ + 'enumerate', 'active_count', 'activeCount', + 'Condition', + 'current_thread', 'currentThread', + 'Event', + 'Lock', 'RLock', + 'Semaphore', 'BoundedSemaphore', + 'Thread', + 'Timer', + 'local', + 'setprofile', 'settrace', 'stack_size' + ] _start_new_thread = thread.start_new_thread _allocate_lock = thread.allocate_lock @@ -581,10 +590,12 @@ class Thread(_Verbose): assert self.__initialized, "Thread.__init__() not called" self.__name = str(name) - def isAlive(self): + def is_alive(self): assert self.__initialized, "Thread.__init__() not called" return self.__started and not self.__stopped + isAlive = is_alive + def isDaemon(self): assert self.__initialized, "Thread.__init__() not called" return self.__daemonic @@ -692,19 +703,23 @@ class _DummyThread(Thread): # Global API functions -def currentThread(): +def current_thread(): try: return _active[_get_ident()] except KeyError: - ##print "currentThread(): no current thread for", _get_ident() + ##print "current_thread(): no current thread for", _get_ident() return _DummyThread() -def activeCount(): +currentThread = current_thread + +def active_count(): _active_limbo_lock.acquire() count = len(_active) + len(_limbo) _active_limbo_lock.release() return count +activeCount = active_count + def enumerate(): _active_limbo_lock.acquire() active = list(_active.values()) + list(_limbo.values())