Skip to content

Conversation

@stephen-ridges
Copy link
Collaborator

@stephen-ridges stephen-ridges commented Dec 11, 2025

EDIT: nvm this doesn't really work. See note below
Docs say:

async def main():  # define a coroutine with `async def`
    sync_sub = Subtensor("finney")  # same as always
    async with AsyncSubtensor("finney") as async_subtensor:  # very important to initialise this with `async with`

source

Also note from this page

Every time the Bittensor Python SDK's Subtensor or AsyncSubtensor class is instantiated, it creates a new websocket connection to Subtensor, Bittensor's Blockchain. Your code should ensure that these websocket connections are handled efficiently and closed when no longer in use by your code.

If not explicitly closed, connections should be terminated by Python's garbage collector, but threading can make this unreliable. (see this comment.)

source


Nvm. For some reason, what the docs suggest causes a memory leak, even with the async with stuff.

Setting weights the first or 2nd time always works in our prod validator, but then it always errors with asyncio.TimeoutError in set_weights_from_mapping(): Max retries exceeded.

But actually what's timing out isn't setting the weights. It's subtensor.get_uid_for_hotkey_on_subnet(hotkey_ss58=weight_receiving_hotkey, netuid=config.NETUID). But I never get the error locally... :thinking_face:

@stephen-ridges stephen-ridges self-assigned this Dec 11, 2025
@stephen-ridges stephen-ridges added the bug Something isn't working label Dec 11, 2025
@stephen-ridges stephen-ridges force-pushed the fix-timeout-registered-and-set-weights branch from 8735525 to da1983c Compare December 11, 2025 19:58
@stephen-ridges stephen-ridges force-pushed the fix-timeout-registered-and-set-weights branch from da1983c to c670413 Compare December 11, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants