15.2.107. camcops_server.cc_modules.cc_debug


Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.

Debugging utilities

camcops_server.cc_modules.cc_debug.makefunc_trace_unique_calls(file_only: bool = False) Callable[[frame, str, Any], Optional[Callable]][source]

Creates a function that you can use as an argument to sys.settrace(). When you execute a trace, it shows only new call to each function.


file_only – Shows files called only, not functions with line numbers.


Decorator to generate profiler output for slow code from camcops_server.cc_debug import profile.

Add @profile to the function you want to profile. Will generate a file called <function name>.profile.

Can be visualised with e.g. SnakeViz (pip install snakeviz)

camcops_server.cc_modules.cc_debug.trace_calls(frame: frame, event: str, arg: Any) Optional[Callable[[frame, str, Any], Optional[Callable]]][source]

A function that can be used as an argument to sys.settrace. It prints details of every function called (filename, line number, function name).