mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-19 14:48:38 +03:00
3b084a165b
* configure isort to add the future annotations import * apply the new isort setting * remove type ignores for new mypy (#13539) https://pypi.org/project/mypy/0.981/ * another
15 lines
381 B
Python
15 lines
381 B
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import logging
|
|
from typing import Optional
|
|
|
|
|
|
def cancel_task_safe(task: Optional[asyncio.Task], log: Optional[logging.Logger] = None):
|
|
if task is not None:
|
|
try:
|
|
task.cancel()
|
|
except Exception as e:
|
|
if log is not None:
|
|
log.error(f"Error while canceling task.{e} {task}")
|