File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -619,21 +619,10 @@ async def async_unregister_all_services(self) -> None:
619619
620620 def unregister_all_services (self ) -> None :
621621 """Unregister all registered services."""
622- # Send Goodbye packets https://datatracker.ietf.org/doc/html/rfc6762#section-10.1
623- out = self .generate_unregister_all_services ()
624- if not out :
625- return
626- now = current_time_millis ()
627- next_time = now
628- i = 0
629- while i < 3 :
630- if now < next_time :
631- self .wait (next_time - now )
632- now = current_time_millis ()
633- continue
634- self .send (out )
635- i += 1
636- next_time += _UNREGISTER_TIME
622+ assert self .loop is not None
623+ run_coro_with_timeout (
624+ self .async_unregister_all_services (), self .loop , _UNREGISTER_TIME * _REGISTER_BROADCASTS
625+ )
637626
638627 async def async_check_service (
639628 self , info : ServiceInfo , allow_name_change : bool , cooperating_responders : bool = False
@@ -799,7 +788,14 @@ def close(self) -> None:
799788
800789 This method is idempotent and irreversible.
801790 """
802- self .unregister_all_services ()
791+ assert self .loop is not None
792+ if self .loop .is_running ():
793+ if self .loop == get_running_loop ():
794+ log .warning (
795+ "unregister_all_services skipped as it does blocking i/o; use AsyncZeroconf with asyncio"
796+ )
797+ else :
798+ self .unregister_all_services ()
803799 self ._close ()
804800 self .engine .close ()
805801 self ._shutdown_threads ()
You can’t perform that action at this time.
0 commit comments