diff options
| author | Sviatoslav Sydorenko <webknjaz@redhat.com> | 2021-06-07 20:00:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 20:00:01 +0200 |
| commit | 499e00995cea4b46b8bb77117fbe316a2f5e8d33 (patch) | |
| tree | 54edc63b59847aef172426cbf5b21ee14c328703 | |
| parent | e00d162892c02a0baf9153e4fe8900334aa54d48 (diff) | |
| parent | 9e54994a178f688e3b1cb00bdd4658d1d7bce743 (diff) | |
| download | cherrypy-git-499e00995cea4b46b8bb77117fbe316a2f5e8d33.tar.gz | |
Merge pull request #1915 from domdfcoding/fix-1914
Use modern threading API instead of deprecated pre-/2.6 camelCase names
| -rw-r--r-- | cherrypy/process/plugins.py | 10 | ||||
| -rw-r--r-- | cherrypy/process/servers.py | 2 | ||||
| -rw-r--r-- | cherrypy/process/wspbus.py | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/cherrypy/process/plugins.py b/cherrypy/process/plugins.py index d2f87a4d..2a9952de 100644 --- a/cherrypy/process/plugins.py +++ b/cherrypy/process/plugins.py @@ -366,7 +366,7 @@ class Daemonizer(SimplePlugin): # "The general problem with making fork() work in a multi-threaded # world is what to do with all of the threads..." # So we check for active threads: - if threading.activeCount() != 1: + if threading.active_count() != 1: self.bus.log('There are %r active threads. ' 'Daemonizing now may cause strange failures.' % threading.enumerate(), level=30) @@ -552,7 +552,7 @@ class Monitor(SimplePlugin): if self.thread is None: self.thread = BackgroundTask(self.frequency, self.callback, bus=self.bus) - self.thread.setName(threadname) + self.thread.name = threadname self.thread.start() self.bus.log('Started monitor thread %r.' % threadname) else: @@ -565,8 +565,8 @@ class Monitor(SimplePlugin): self.bus.log('No thread running for %s.' % self.name or self.__class__.__name__) else: - if self.thread is not threading.currentThread(): - name = self.thread.getName() + if self.thread is not threading.current_thread(): + name = self.thread.name self.thread.cancel() if not self.thread.daemon: self.bus.log('Joining %r' % name) @@ -692,7 +692,7 @@ class Autoreloader(Monitor): filename) self.thread.cancel() self.bus.log('Stopped thread %r.' % - self.thread.getName()) + self.thread.name) self.bus.restart() return diff --git a/cherrypy/process/servers.py b/cherrypy/process/servers.py index dcb34de6..717a8de0 100644 --- a/cherrypy/process/servers.py +++ b/cherrypy/process/servers.py @@ -178,7 +178,7 @@ class ServerAdapter(object): import threading t = threading.Thread(target=self._start_http_thread) - t.setName('HTTPServer ' + t.getName()) + t.name = 'HTTPServer ' + t.name t.start() self.wait() diff --git a/cherrypy/process/wspbus.py b/cherrypy/process/wspbus.py index ead90a4e..1d2789b1 100644 --- a/cherrypy/process/wspbus.py +++ b/cherrypy/process/wspbus.py @@ -356,13 +356,13 @@ class Bus(object): # implemented as a windows service and in any other case # that another thread executes cherrypy.engine.exit() if ( - t != threading.currentThread() and + t != threading.current_thread() and not isinstance(t, threading._MainThread) and # Note that any dummy (external) threads are # always daemonic. not t.daemon ): - self.log('Waiting for thread %s.' % t.getName()) + self.log('Waiting for thread %s.' % t.name) t.join() if self.execv: @@ -570,7 +570,7 @@ class Bus(object): self.wait(states.STARTED) func(*a, **kw) t = threading.Thread(target=_callback, args=args, kwargs=kwargs) - t.setName('Bus Callback ' + t.getName()) + t.name = 'Bus Callback ' + t.name t.start() self.start() |
