Commit c5273402 authored by Stéphane Blondon's avatar Stéphane Blondon

replace deprecated occurences of Thread.isAlive() by Thread.is_alive()

parent e3517548
...@@ -939,7 +939,7 @@ class StorageServer(object): ...@@ -939,7 +939,7 @@ class StorageServer(object):
status['connections'] = len(status['connections']) status['connections'] = len(status['connections'])
lock_manager = self.lock_managers[storage_id] lock_manager = self.lock_managers[storage_id]
status['waiting'] = len(lock_manager.waiting) status['waiting'] = len(lock_manager.waiting)
status['timeout-thread-is-alive'] = lock_manager.timeout.isAlive() status['timeout-thread-is-alive'] = lock_manager.timeout.is_alive()
last_transaction = self.storages[storage_id].lastTransaction() last_transaction = self.storages[storage_id].lastTransaction()
last_transaction_hex = codecs.encode(last_transaction, 'hex_codec') last_transaction_hex = codecs.encode(last_transaction, 'hex_codec')
if PY3: if PY3:
...@@ -960,7 +960,7 @@ class StubTimeoutThread(object): ...@@ -960,7 +960,7 @@ class StubTimeoutThread(object):
def end(self, client): def end(self, client):
pass pass
isAlive = lambda self: 'stub' is_alive = lambda self: 'stub'
class TimeoutThread(threading.Thread): class TimeoutThread(threading.Thread):
......
...@@ -493,7 +493,7 @@ class ConnectionTests(CommonSetupTearDown): ...@@ -493,7 +493,7 @@ class ConnectionTests(CommonSetupTearDown):
# Wait for all threads to finish # Wait for all threads to finish
for t in threads: for t in threads:
t.join(60) t.join(60)
self.assertFalse(t.isAlive(), "%s didn't die" % t.getName()) self.assertFalse(t.is_alive(), "%s didn't die" % t.getName())
finally: finally:
for t in threads: for t in threads:
t.closeclients() t.closeclients()
......
...@@ -53,5 +53,5 @@ class TestThread(threading.Thread): ...@@ -53,5 +53,5 @@ class TestThread(threading.Thread):
self.join(timeout) self.join(timeout)
if self._exc_info: if self._exc_info:
six.reraise(self._exc_info[0], self._exc_info[1], self._exc_info[2]) six.reraise(self._exc_info[0], self._exc_info[1], self._exc_info[2])
if self.isAlive(): if self.is_alive():
self._testcase.fail("Thread did not finish: %s" % self) self._testcase.fail("Thread did not finish: %s" % self)
...@@ -34,7 +34,7 @@ class BasicThread(threading.Thread): ...@@ -34,7 +34,7 @@ class BasicThread(threading.Thread):
def join(self): def join(self):
threading.Thread.join(self, 10) threading.Thread.join(self, 10)
assert not self.isAlive() assert not self.is_alive()
class GetsThroughVoteThread(BasicThread): class GetsThroughVoteThread(BasicThread):
...@@ -119,7 +119,7 @@ class ThreadTests(object): ...@@ -119,7 +119,7 @@ class ThreadTests(object):
for t in threads: for t in threads:
t.join(30) t.join(30)
for i in threads: for i in threads:
self.assertFalse(t.isAlive()) self.assertFalse(t.is_alive())
# Helper for checkMTStores # Helper for checkMTStores
def mtstorehelper(self): def mtstorehelper(self):
......
...@@ -1307,7 +1307,7 @@ class StorageServer(object): ...@@ -1307,7 +1307,7 @@ class StorageServer(object):
status = self.stats[storage_id].__dict__.copy() status = self.stats[storage_id].__dict__.copy()
status['connections'] = len(status['connections']) status['connections'] = len(status['connections'])
status['waiting'] = len(self._waiting[storage_id]) status['waiting'] = len(self._waiting[storage_id])
status['timeout-thread-is-alive'] = self.timeouts[storage_id].isAlive() status['timeout-thread-is-alive'] = self.timeouts[storage_id].is_alive()
last_transaction = self.storages[storage_id].lastTransaction() last_transaction = self.storages[storage_id].lastTransaction()
last_transaction_hex = codecs.encode(last_transaction, 'hex_codec') last_transaction_hex = codecs.encode(last_transaction, 'hex_codec')
if PY3: if PY3:
...@@ -1336,7 +1336,7 @@ class StubTimeoutThread(object): ...@@ -1336,7 +1336,7 @@ class StubTimeoutThread(object):
def end(self, client): def end(self, client):
pass pass
isAlive = lambda self: 'stub' is_alive = lambda self: 'stub'
class TimeoutThread(threading.Thread): class TimeoutThread(threading.Thread):
......
...@@ -218,7 +218,7 @@ class ConnectionManager(object): ...@@ -218,7 +218,7 @@ class ConnectionManager(object):
log("CM.close(): stopping and joining thread") log("CM.close(): stopping and joining thread")
t.stop() t.stop()
t.join(30) t.join(30)
if t.isAlive(): if t.is_alive():
log("CM.close(): self.thread.join() timed out", log("CM.close(): self.thread.join() timed out",
level=logging.WARNING) level=logging.WARNING)
...@@ -288,7 +288,7 @@ class ConnectionManager(object): ...@@ -288,7 +288,7 @@ class ConnectionManager(object):
t.setDaemon(1) t.setDaemon(1)
t.start() t.start()
if sync: if sync:
while self.connection is None and t.isAlive(): while self.connection is None and t.is_alive():
self.cond.wait(self.sync_wait) self.cond.wait(self.sync_wait)
if self.connection is None: if self.connection is None:
log("CM.connect(sync=1): still waiting...") log("CM.connect(sync=1): still waiting...")
......
...@@ -213,7 +213,7 @@ This tests tries to provoke this bug by: ...@@ -213,7 +213,7 @@ This tests tries to provoke this bug by:
... stop = True ... stop = True
... thread.join(10) ... thread.join(10)
>>> thread.isAlive() >>> thread.is_alive()
False False
>>> for record in handler.records: >>> for record in handler.records:
......
...@@ -136,7 +136,7 @@ provoke problems: ...@@ -136,7 +136,7 @@ provoke problems:
... thread.start() ... thread.start()
>>> for thread in threads: >>> for thread in threads:
... thread.join(99) ... thread.join(99)
... if thread.isAlive(): ... if thread.is_alive():
... print("Can't join thread.") ... print("Can't join thread.")
>>> wait_until("size is reduced", check, 99, onfail) >>> wait_until("size is reduced", check, 99, onfail)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment