Merge "Remove fallback to time.clock()"
This commit is contained in:
commit
30567b4c75
@ -10,12 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
try:
|
import time
|
||||||
# Python 3.8 : time.clock was deprecated and removed.
|
|
||||||
from time import perf_counter as clock
|
|
||||||
except ImportError:
|
|
||||||
from time import clock
|
|
||||||
|
|
||||||
|
|
||||||
from etcd3gw.client import Etcd3Client
|
from etcd3gw.client import Etcd3Client
|
||||||
from etcd3gw.lock import Lock
|
from etcd3gw.lock import Lock
|
||||||
@ -59,7 +54,7 @@ def main():
|
|||||||
print("Key delete foo-unknown : %r" % result)
|
print("Key delete foo-unknown : %r" % result)
|
||||||
|
|
||||||
print('>>>> Lock')
|
print('>>>> Lock')
|
||||||
lock = Lock('xyz-%s' % clock(), ttl=10000, client=client)
|
lock = Lock('xyz-%s' % time.perf_counter(), ttl=10000, client=client)
|
||||||
result = lock.acquire()
|
result = lock.acquire()
|
||||||
print("acquire : %r" % result)
|
print("acquire : %r" % result)
|
||||||
result = lock.refresh()
|
result = lock.refresh()
|
||||||
|
@ -33,12 +33,6 @@ from etcd3gw import exceptions
|
|||||||
from etcd3gw.tests import base
|
from etcd3gw.tests import base
|
||||||
from etcd3gw import utils
|
from etcd3gw import utils
|
||||||
|
|
||||||
try:
|
|
||||||
# Python 3.8 : time.clock was deprecated and removed.
|
|
||||||
from time import perf_counter as clock
|
|
||||||
except ImportError:
|
|
||||||
from time import clock
|
|
||||||
|
|
||||||
|
|
||||||
def _is_etcd3_running():
|
def _is_etcd3_running():
|
||||||
try:
|
try:
|
||||||
@ -413,7 +407,7 @@ class TestEtcd3Gateway(base.TestCase):
|
|||||||
@unittest.skipUnless(
|
@unittest.skipUnless(
|
||||||
_is_etcd3_running(), "etcd3 is not available")
|
_is_etcd3_running(), "etcd3 is not available")
|
||||||
def test_client_locks(self):
|
def test_client_locks(self):
|
||||||
lock = self.client.lock(id='xyz-%s' % clock(), ttl=60)
|
lock = self.client.lock(id='xyz-%s' % time.perf_counter(), ttl=60)
|
||||||
self.assertIsNotNone(lock)
|
self.assertIsNotNone(lock)
|
||||||
|
|
||||||
self.assertTrue(lock.acquire())
|
self.assertTrue(lock.acquire())
|
||||||
|
Loading…
Reference in New Issue
Block a user