[FIX] tools: fix profiler datetime usage

This commit fixes the profiler datetime usage by properly using the
'real_datetime_now' as a callable.

This was breaking the output json file when profiling.

closes odoo/odoo#96456

X-original-commit: 5fec27e42b033f79933afb3d0c85b142360981f9
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Aurélien Warnon
2022-07-25 07:51:02 +02:00
parent 3b59b26967
commit 2160315869
+2 -2
View File
@@ -647,7 +647,7 @@ class Profiler:
This is mainly useful to uniquify a path between executions.
"""
return path.format(
time=real_datetime_now.strftime("%Y%m%d-%H%M%S"),
time=real_datetime_now().strftime("%Y%m%d-%H%M%S"),
len=self.entry_count(),
desc=re.sub("[^0-9a-zA-Z-]+", "_", self.description)
)
@@ -667,7 +667,7 @@ class Profiler:
return json.dumps({
"name": self.description,
"session": self.profile_session,
"create_date": real_datetime_now.strftime("%Y%m%d-%H%M%S"),
"create_date": real_datetime_now().strftime("%Y%m%d-%H%M%S"),
"init_stack_trace": _format_stack(self.init_stack_trace),
"duration": self.duration,
"collectors": {collector.name: collector.entries for collector in self.collectors},