This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @contextmanager | |
| def avoid( | |
| exception: type(Exception), | |
| raises: Exception = None, | |
| exception_manager: Callable = None, | |
| finally_manager: Callable = lambda: (), | |
| ): | |
| try: | |
| yield | |
| except exception as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @contextlib.contextmanager | |
| def no_stdout(): | |
| save_stdout = sys.stdout | |
| sys.stdout = io.BytesIO() | |
| yield | |
| sys.stdout = save_stdout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def timeit(n): | |
| def timeit_decorator(func): | |
| async def process(func, *args, **params): | |
| if asyncio.iscoroutinefunction(func): | |
| return await func(*args, **params) | |
| else: | |
| return func(*args, **params) | |
| async def helper(*args, **params): | |
| times = [] |
OlderNewer