Skip to content

Commit

Permalink
Merge pull request #2186 from opentensor/fix/multiprocessing-pow
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking authored Jul 29, 2024
2 parents 7895c02 + a25b879 commit 36b9b0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions bittensor/utils/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _get_real_torch():


def log_no_torch_error():
bittensor.btlogging.error(
bittensor.logging.error(
"This command requires torch. You can install torch for bittensor"
' with `pip install bittensor[torch]` or `pip install ".[torch]"`'
" if installing from source, and then run the command with USE_TORCH=1 {command}"
Expand Down Expand Up @@ -562,7 +562,7 @@ def _solve_for_difficulty_fast(
while still updating the block information after a different number of nonces,
to increase the transparency of the process while still keeping the speed.
"""
if num_processes == None:
if num_processes is None:
# get the number of allowed processes for this process
num_processes = min(1, get_cpu_count())

Expand Down Expand Up @@ -780,7 +780,7 @@ def __init__(self, force: bool = False):

def __enter__(self):
self._old_start_method = multiprocessing.get_start_method(allow_none=True)
if self._old_start_method == None:
if self._old_start_method is None:
self._old_start_method = "spawn" # default to spawn

multiprocessing.set_start_method("spawn", force=self._force)
Expand Down Expand Up @@ -1089,6 +1089,7 @@ def _terminate_workers_and_wait_for_exit(
if isinstance(worker, multiprocessing.queues.Queue):
worker.join_thread()
else:
worker.terminate()
worker.join()
worker.close()

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/utils/test_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def error(self, message):
@pytest.fixture
def mock_bittensor_logging(monkeypatch):
mock_logger = MockBittensorLogging()
monkeypatch.setattr("bittensor.btlogging", mock_logger)
monkeypatch.setattr("bittensor.logging", mock_logger)
return mock_logger


Expand Down

0 comments on commit 36b9b0c

Please sign in to comment.