MCPcopy Create free account
hub / github.com/ambianic/peerfetch / make_discoverable

Function make_discoverable

python/src/peerfetch/proxy.py:330–361  ·  view source on GitHub ↗

Enable remote peers to find and connect to this peer.

(peer=None)

Source from the content-addressed store, hash-verified

328
329
330async def make_discoverable(peer=None):
331 """Enable remote peers to find and connect to this peer."""
332 logger.debug('Enter peer discoverable.')
333 logger.debug('Before _is_shutting_down')
334 global _is_shutting_down
335 logger.debug('Making peer discoverable.')
336 while not _is_shutting_down:
337 logger.debug('Discovery loop.')
338 logger.debug('peer status: {}', peer)
339 try:
340 if not peer or peer.destroyed:
341 logger.info('Peer destroyed. Will create a new peer.')
342 peer = await pnp_service_connect()
343 elif peer.open:
344 await join_peer_room(peer=peer)
345 elif peer.disconnected:
346 logger.info('Peer disconnected. Will try to reconnect.')
347 await peer.reconnect()
348 else:
349 logger.info('Peer still establishing connection. {}', peer)
350 except Exception as e:
351 logger.exception('Error while trying to join local peer room. '
352 'Will retry in a few moments. '
353 'Error: \n{}', e)
354 if peer and not peer.destroyed:
355 # something is not right with the connection to the server
356 # lets start a fresh peer connection
357 logger.info('Peer connection was corrupted. Detroying peer.')
358 await peer.destroy()
359 peer = None
360 logger.debug('peer status after destroy: {}', peer)
361 await asyncio.sleep(3)
362
363
364def _config_logger():

Callers 1

_startFunction · 0.85

Calls 2

pnp_service_connectFunction · 0.85
join_peer_roomFunction · 0.85

Tested by

no test coverage detected