Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions hathor/consensus/block_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
from structlog import get_logger

from hathor.conf.get_settings import get_global_settings
from hathor.profiler import get_cpu_profiler
from hathor.transaction import BaseTransaction, Block, Transaction, sum_weights
from hathor.util import classproperty

if TYPE_CHECKING:
from hathor.consensus.context import ConsensusAlgorithmContext

logger = get_logger()
cpu = get_cpu_profiler()

_base_transaction_log = logger.new()

Expand Down
2 changes: 0 additions & 2 deletions hathor/consensus/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from structlog import get_logger

from hathor.profiler import get_cpu_profiler
from hathor.pubsub import PubSubManager
from hathor.transaction import BaseTransaction, Block

Expand All @@ -26,7 +25,6 @@
from hathor.consensus.transaction_consensus import TransactionConsensusAlgorithm

logger = get_logger()
cpu = get_cpu_profiler()

_base_transaction_log = logger.new()

Expand Down
2 changes: 0 additions & 2 deletions hathor/consensus/transaction_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
from structlog import get_logger

from hathor.conf.get_settings import get_global_settings
from hathor.profiler import get_cpu_profiler
from hathor.transaction import BaseTransaction, Block, Transaction, TxInput, sum_weights
from hathor.util import classproperty

if TYPE_CHECKING:
from hathor.consensus.context import ConsensusAlgorithmContext

logger = get_logger()
cpu = get_cpu_profiler()

_base_transaction_log = logger.new()

Expand Down
4 changes: 3 additions & 1 deletion hathor/profiler/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, *, update_interval: float = 3.0, expiry: float = 15.0):
self.proc_list: list[tuple[Key, ProcItem]] = []

# Timer to call `self.update()` periodically.
self.lc_update = LoopingCall(self.update)
self.lc_update: LoopingCall | None = None

# Interval to update the list of processes.
self.update_interval = update_interval
Expand Down Expand Up @@ -102,13 +102,15 @@ def start(self) -> None:
return
self.reset()
self.enabled = True
self.lc_update = LoopingCall(self.update)
self.lc_update.start(self.update_interval)

def stop(self) -> None:
"""Stop the profiler."""
if not self.enabled:
return
self.enabled = False
assert self.lc_update is not None
self.lc_update.stop()

def get_proc_list(self) -> list[tuple[Key, ProcItem]]:
Expand Down
4 changes: 3 additions & 1 deletion hathor/reactor/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def initialize_global_reactor(*, use_asyncio_reactor: bool = False) -> ReactorPr
msg = (
"There's a Twisted reactor installed already. It's probably the default one, installed indirectly by "
"one of our imports. This can happen, for example, if we import from the hathor module in "
"entrypoint-level, like in CLI tools other than `RunNode`."
"entrypoint-level, like in CLI tools other than `RunNode`. Debug it by setting a breakpoint in "
"`installReactor()` in the `twisted/internet/main.py` file."

)
raise Exception(msg) from e

Expand Down
3 changes: 0 additions & 3 deletions hathor/transaction/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from hathor.checkpoint import Checkpoint
from hathor.feature_activation.feature import Feature
from hathor.feature_activation.model.feature_state import FeatureState
from hathor.profiler import get_cpu_profiler
from hathor.transaction import BaseTransaction, TxOutput, TxVersion
from hathor.transaction.exceptions import CheckpointError
from hathor.transaction.util import VerboseCallback, int_to_bytes, unpack, unpack_len
Expand All @@ -31,8 +30,6 @@
if TYPE_CHECKING:
from hathor.transaction.storage import TransactionStorage # noqa: F401

cpu = get_cpu_profiler()

# Signal bits (B), version (B), outputs len (B)
_FUNDS_FORMAT_STRING = '!BBB'

Expand Down
3 changes: 0 additions & 3 deletions hathor/transaction/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from hathor.checkpoint import Checkpoint
from hathor.exception import InvalidNewTransaction
from hathor.profiler import get_cpu_profiler
from hathor.reward_lock import iter_spent_rewards
from hathor.transaction import BaseTransaction, TxInput, TxOutput, TxVersion
from hathor.transaction.base_transaction import TX_HASH_SIZE
Expand All @@ -31,8 +30,6 @@
if TYPE_CHECKING:
from hathor.transaction.storage import TransactionStorage # noqa: F401

cpu = get_cpu_profiler()

# Signal bits (B), version (B), token uids len (B) and inputs len (B), outputs len (B).
_FUNDS_FORMAT_STRING = '!BBBBB'

Expand Down