mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 19:30:04 +01:00
display the time taken
This commit is contained in:
parent
630160f592
commit
92c42b9c8c
@ -30,19 +30,23 @@ from waflib import Task
|
|||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
|
|
||||||
def lock_maxjob(self):
|
def lock_maxjob(self):
|
||||||
|
# lock the file, telling other build processes to avoid spawining tasks during that time
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.lockfd = os.open(self.generator.bld.lockfile, os.O_TRUNC | os.O_CREAT | os.O_RDWR)
|
self.lockfd = os.open(self.generator.bld.lockfile, os.O_TRUNC | os.O_CREAT | os.O_RDWR)
|
||||||
fcntl.flock(self.lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
fcntl.flock(self.lockfd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
except (OSError, IOError), e:
|
except (OSError, IOError), e:
|
||||||
if e.errno in (errno.EACCES, errno.EAGAIN):
|
if e.errno in (errno.EACCES, errno.EAGAIN):
|
||||||
time.sleep(0.1)
|
time.sleep(0.3)
|
||||||
continue
|
continue
|
||||||
raise
|
raise
|
||||||
os.write(self.lockfd, "%d" % os.getpid())
|
os.write(self.lockfd, "%d" % os.getpid())
|
||||||
|
self.start_time = time.time()
|
||||||
break
|
break
|
||||||
|
|
||||||
def release_maxjob(self):
|
def release_maxjob(self):
|
||||||
|
# release the lock file
|
||||||
|
print "> long task %d" % (time.time() - self.start_time)
|
||||||
try:
|
try:
|
||||||
os.unlink(self.generator.bld.lockfile)
|
os.unlink(self.generator.bld.lockfile)
|
||||||
os.close(self.lockfd)
|
os.close(self.lockfd)
|
||||||
@ -52,6 +56,7 @@ def release_maxjob(self):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def wait_maxjob(self):
|
def wait_maxjob(self):
|
||||||
|
# wait on the lock file.. up to a certain limit
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
ini = os.stat(self.generator.bld.lockfile).st_mtime
|
ini = os.stat(self.generator.bld.lockfile).st_mtime
|
||||||
@ -60,7 +65,7 @@ def wait_maxjob(self):
|
|||||||
diff = time.time() - ini
|
diff = time.time() - ini
|
||||||
if diff > 300: # stale lock file? wait 5 minutes
|
if diff > 300: # stale lock file? wait 5 minutes
|
||||||
return
|
return
|
||||||
time.sleep(0.1)
|
time.sleep(0.5)
|
||||||
|
|
||||||
# the method process is called by threads...
|
# the method process is called by threads...
|
||||||
def process2(self):
|
def process2(self):
|
||||||
@ -83,6 +88,7 @@ def process2(self):
|
|||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
try:
|
try:
|
||||||
process2(self)
|
process2(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user