From a143733ccf3acce588ffb588aa641c3251232c8b Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 18 May 2014 11:18:00 +0200 Subject: [PATCH] Made lockhandler write lockwarnings to separate log file --- src/locks/lockhandler.py | 7 ++++--- src/utils/dummyrunner/memplot.py | 13 ++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/locks/lockhandler.py b/src/locks/lockhandler.py index 9f90348bf3..8360ff79f4 100644 --- a/src/locks/lockhandler.py +++ b/src/locks/lockhandler.py @@ -113,6 +113,7 @@ from django.utils.translation import ugettext as _ __all__ = ("LockHandler", "LockException") +WARNING_LOG = "lockwarnings.log" # # Exception class. This will be raised @@ -232,12 +233,12 @@ class LockHandler(object): continue if access_type in locks: duplicates += 1 - wlist.append(_("Lock: access type '%(access_type)s' changed from '%(source)s' to '%(goal)s' " % \ - {"access_type":access_type, "source":locks[access_type][2], "goal":raw_lockstring})) + wlist.append(_("LockHandler on %(obj)s: access type '%(access_type)s' changed from '%(source)s' to '%(goal)s' " % \ + {"obj":self.obj, "access_type":access_type, "source":locks[access_type][2], "goal":raw_lockstring})) locks[access_type] = (evalstring, tuple(lock_funcs), raw_lockstring) if wlist: # a warning text was set, it's not an error, so only report - logger.log_warn("\n".join(wlist)) + logger.log_file("\n".join(wlist), WARNING_LOG) if elist: # an error text was set, raise exception. raise LockException("\n".join(elist)) diff --git a/src/utils/dummyrunner/memplot.py b/src/utils/dummyrunner/memplot.py index 459a60c265..44a8129aa2 100644 --- a/src/utils/dummyrunner/memplot.py +++ b/src/utils/dummyrunner/memplot.py @@ -34,7 +34,7 @@ class Memplot(ev.Script): t0 = (time.time() - self.db.starttime) / 60.0 # save in minutes with open(LOGFILE, "a") as f: - f.write("%s, %s, %s, %s\n" % (t0, rmem, vmem, total_num)) + f.write("%s, %s, %s, %s\n" % (t0, rmem, vmem, int(total_num))) if __name__ == "__main__": @@ -43,19 +43,14 @@ if __name__ == "__main__": from matplotlib import pyplot as pp import numpy - data = numpy.genfromtxt(LOGFILE, delimiter=",") + data = numpy.genfromtxt("../../../game/" + LOGFILE, delimiter=",") secs = data[:,0] rmem = data[:,1] vmem = data[:,2] nobj = data[:,3] - # correct for @reload - #secs[359:] = secs[359:] + secs[358] - # count total amount of objects - ntot = data[:,3].copy() - #ntot[119:] = ntot[119:] + ntot[118] - ntot[119] - #ntot[359:] = ntot[359:] + ntot[358] - ntot[359] + #ntot = data[:,3].copy() fig = pp.figure() ax1 = fig.add_subplot(111) @@ -68,7 +63,7 @@ if __name__ == "__main__": ax2 = ax1.twinx() ax2.plot(secs, nobj, "g--", label="objs in cache", lw=2) - ax2.plot(secs, ntot, "r--", label="objs total", lw=2) + #ax2.plot(secs, ntot, "r--", label="objs total", lw=2) ax2.set_ylabel("Number of objects") ax2.legend(loc="lower right") ax2.annotate("idmapper\nflush", xy=(70,480))