(self)
| 203 | return self |
| 204 | |
| 205 | def dump(self): |
| 206 | if self._dump_callback is not None: |
| 207 | if not os.path.exists(self._path): |
| 208 | os.makedirs(self._path) |
| 209 | if not os.path.isdir(self._path): |
| 210 | get_logger().warning( |
| 211 | "{} is not a directory, cannot write profiling results".format( |
| 212 | self._path |
| 213 | ) |
| 214 | ) |
| 215 | return |
| 216 | for format in self._formats: |
| 217 | path = self.format_path(self._path, self._pid, format) |
| 218 | get_logger().info("process {} generating {}".format(self._pid, format)) |
| 219 | self._dump_callback(path, format) |
| 220 | get_logger().info("profiling results written to {}".format(path)) |
| 221 | if os.path.getsize(path) > 64 * 1024 * 1024: |
| 222 | get_logger().warning( |
| 223 | "profiling results too large, maybe you are profiling multi iters," |
| 224 | "consider attach profiler in each iter separately" |
| 225 | ) |
| 226 | self._dump_callback = None |
| 227 | _living_profilers.remove(self) |
| 228 | |
| 229 | def format_path(self, path, pid, format): |
| 230 | return os.path.join(path, "{}.{}".format(pid, format)) |
no test coverage detected