Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Conversation

gsalgado
Copy link
Contributor

@gsalgado gsalgado commented May 24, 2018

  • Ensure PeerPool never runs multiple node discovery lookups in parallel
  • KademliaProtocol.bond() no longer triggers
    self.populate_not_full_buckets() when bondig fails as that can
    potentially create a never-ending bonding spiral

The AlreadyWaiting errors (#737) seem to be gone with these changes

@gsalgado gsalgado requested a review from pipermerriam May 24, 2018 15:28
Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the Lock request

p2p/peer.py Outdated
if self._discovery_lookup_running:
self.logger.debug("Node discovery lookup already in progress, not running another")
return
self._discovery_lookup_running = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an asyncio.Lock for this instead of a true/false? They support use as a context manager which allows for a cleaner API here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! Should've thought of that myself

p2p/peer.py Outdated
async def maybe_lookup_random_node(self) -> None:
if self._discovery_last_lookup + self._discovery_lookup_interval > time.time():
return
if self._discovery_lookup_running:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick

Can you make this an elif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing

@gsalgado gsalgado force-pushed the peer-pool-discovery-fixes branch from de5ee62 to e34496c Compare May 24, 2018 15:42
p2p/peer.py Outdated
elif self._discovery_lookup_running.locked():
self.logger.debug("Node discovery lookup already in progress, not running another")
return
with (await self._discovery_lookup_running):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this equvalent to async with self.discovery_lookup_running?

That's what I found here: https://www.pythonsheets.com/notes/python-asyncio.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it: https://www.python.org/dev/peps/pep-0492/#asynchronous-context-managers-and-async-with

I'll switch to async with; I think that reads better

- Ensure PeerPool never runs multiple node discovery lookups in parallel
- KademliaProtocol.bond() no longer triggers
  self.populate_not_full_buckets() when bondig fails as that can
  potentially create a never-ending bonding spiral
@gsalgado gsalgado force-pushed the peer-pool-discovery-fixes branch from e34496c to 2d60366 Compare May 24, 2018 16:45
@gsalgado gsalgado merged commit 92511b3 into ethereum:master May 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants