File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2424
2525import asyncio
2626import logging
27+ import random
2728import sys
2829import threading
2930from collections .abc import Awaitable
@@ -544,6 +545,11 @@ async def async_check_service(
544545 instance_name = instance_name_from_service_info (info , strict = strict )
545546 if cooperating_responders :
546547 return
548+
549+ # Wait a random amount of time up avoid collisions and avoid
550+ # a thundering herd when multiple services are started on the network
551+ await self .async_wait (random .randint (150 , 250 ))
552+
547553 next_instance_number = 2
548554 next_time = now = current_time_millis ()
549555 i = 0
Original file line number Diff line number Diff line change 2828# Some timing constants
2929
3030_UNREGISTER_TIME = 125 # ms
31- _CHECK_TIME = 175 # ms
31+ _CHECK_TIME = 500 # ms
3232_REGISTER_TIME = 225 # ms
3333_LISTENER_TIME = 200 # ms
3434_BROWSER_TIME = 10000 # ms
You can’t perform that action at this time.
0 commit comments