From e4ce79f720c6b9054983bdd0fc7b0eb0e13c7860 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 16 Jan 2024 10:25:55 -0500 Subject: [PATCH] Delegate `.toolz.open_crash_handler()` to `tractor.devx` Means we can drop `.toolz.debug` module outright. --- piker/brokers/cli.py | 10 ++++++---- piker/toolz/__init__.py | 24 ++++++------------------ piker/toolz/debug.py | 40 ---------------------------------------- 3 files changed, 12 insertions(+), 62 deletions(-) delete mode 100644 piker/toolz/debug.py diff --git a/piker/brokers/cli.py b/piker/brokers/cli.py index d48ae6e5..d54b2203 100644 --- a/piker/brokers/cli.py +++ b/piker/brokers/cli.py @@ -482,7 +482,7 @@ def search( ): return await func() - from cornerboi._debug import open_crash_handler + from piker.toolz import open_crash_handler with open_crash_handler(): quotes = trio.run( main, @@ -506,9 +506,11 @@ def search( @click.option('--delete', '-d', flag_value=True, help='Delete section') @click.pass_obj def brokercfg(config, section, value, delete): - """If invoked with no arguments, open an editor to edit broker configs file - or get / update an individual section. - """ + ''' + If invoked with no arguments, open an editor to edit broker + configs file or get / update an individual section. + + ''' from .. import config if section: diff --git a/piker/toolz/__init__.py b/piker/toolz/__init__.py index 3069504e..b6136504 100644 --- a/piker/toolz/__init__.py +++ b/piker/toolz/__init__.py @@ -18,24 +18,12 @@ Toolz for debug, profile and trace of the distributed runtime :surfer: ''' -from .debug import ( - open_crash_handler, +from tractor.devx import ( + open_crash_handler as open_crash_handler, ) from .profile import ( - Profiler, - pg_profile_enabled, - ms_slower_then, - timeit, + Profiler as Profiler, + pg_profile_enabled as pg_profile_enabled, + ms_slower_then as ms_slower_then, + timeit as timeit, ) - -# TODO: other mods to include? -# - DROP .trionics, already moved into tractor -# - move in `piker.calc` - -__all__: list[str] = [ - 'open_crash_handler', - 'pg_profile_enabled', - 'ms_slower_then', - 'Profiler', - 'timeit', -] diff --git a/piker/toolz/debug.py b/piker/toolz/debug.py deleted file mode 100644 index 3b8a3e3e..00000000 --- a/piker/toolz/debug.py +++ /dev/null @@ -1,40 +0,0 @@ -# piker: trading gear for hackers -# Copyright (C) Tyler Goodlet (in stewardship for pikers) - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program 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 Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -''' -Debugger wrappers for `pdbp` as used by `tractor`. - -''' -from contextlib import contextmanager as cm - -import pdbp - - -# TODO: better naming and what additionals? -# - optional runtime plugging? -# - detection for sync vs. async code? -# - specialized REPL entry when in distributed mode? -@cm -def open_crash_handler(): - ''' - Super basic crash handler using `pdbp` debugger. - - ''' - try: - yield - except BaseException: - pdbp.xpm() - raise