You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2020/09/16 23:33:08 UTC

[kudu] 03/03: Fix assign-location.py on Python 3.8+

This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 5c22c99d5902a56bab64f19329a8fd1e12d186fd
Author: Grant Henke <gr...@apache.org>
AuthorDate: Wed Sep 16 16:34:18 2020 -0500

    Fix assign-location.py on Python 3.8+
    
    Python 3.8+ removed time.clock() in favor of various other
    clock options. This patch fixes assign-location.py to be
    Python 3.8+ compatible by using time.time() instead.
    We use this in other Python scripts for similar deadline
    functionality.
    
    Change-Id: I21f9f8bc519a7286d17a012404b074494461e571
    Reviewed-on: http://gerrit.cloudera.org:8080/16461
    Reviewed-by: Alexey Serbin <as...@cloudera.com>
    Reviewed-by: Andrew Wong <aw...@cloudera.com>
    Tested-by: Grant Henke <gr...@apache.org>
---
 src/kudu/scripts/assign-location.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/kudu/scripts/assign-location.py b/src/kudu/scripts/assign-location.py
index 4601967..8ab8aee 100644
--- a/src/kudu/scripts/assign-location.py
+++ b/src/kudu/scripts/assign-location.py
@@ -92,21 +92,20 @@ class LocationAssignmentRule(object):
     else:
       return ""
 
-
 def acquire_advisory_lock(fpath):
   """
   Acquire a lock on a special .lock file. Don't block while trying: return
   if failed to acquire a lock in 30 seconds.
   """
   timeout_seconds = 30
-  now = time.clock()
+  now = time.time()
   deadline = now + timeout_seconds
   random.seed(int(now))
   fpath_lock_file = fpath + ".lock"
   # Open the lock file; create the file if doesn't exist.
   lock_file = open(fpath_lock_file, 'w+')
   got_lock = False
-  while time.clock() < deadline:
+  while time.time() < deadline:
     try:
       fcntl.flock(lock_file, fcntl.LOCK_EX | fcntl.LOCK_NB)
       got_lock = True