forked from platypush/platypush
Unregister a Zeroconf instance if it already exists before publishing a backend service.
`mdns` connection are another culprit for the increasing number of open files in the process.
This commit is contained in:
parent
33d4c8342d
commit
4972c8bdcf
2 changed files with 9 additions and 6 deletions
|
@ -402,6 +402,13 @@ class Backend(Thread, EventGenerator, ExtensionWithManifest):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.zeroconf:
|
||||||
|
self.logger.info(
|
||||||
|
'Zeroconf service already registered for %s, removing the previous instance',
|
||||||
|
self.__class__.__name__,
|
||||||
|
)
|
||||||
|
self.unregister_service()
|
||||||
|
|
||||||
self.zeroconf = Zeroconf()
|
self.zeroconf = Zeroconf()
|
||||||
srv_desc = {
|
srv_desc = {
|
||||||
'name': 'Platypush',
|
'name': 'Platypush',
|
||||||
|
|
|
@ -46,9 +46,7 @@ class ZeroconfListener(ServiceListener):
|
||||||
'properties': {
|
'properties': {
|
||||||
k.decode()
|
k.decode()
|
||||||
if isinstance(k, bytes)
|
if isinstance(k, bytes)
|
||||||
else k: v.decode()
|
else k: (v.decode() if isinstance(v, bytes) else v)
|
||||||
if isinstance(v, bytes)
|
|
||||||
else v
|
|
||||||
for k, v in info.properties.items()
|
for k, v in info.properties.items()
|
||||||
},
|
},
|
||||||
'server': info.server,
|
'server': info.server,
|
||||||
|
@ -166,9 +164,7 @@ class ZeroconfPlugin(Plugin):
|
||||||
get_bus().post(evt)
|
get_bus().post(evt)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
if not services:
|
if not services:
|
||||||
self.logger.warning(
|
self.logger.warning('No such service discovered: %s', service)
|
||||||
'No such service discovered: {}'.format(service)
|
|
||||||
)
|
|
||||||
finally:
|
finally:
|
||||||
if browser:
|
if browser:
|
||||||
browser.cancel()
|
browser.cancel()
|
||||||
|
|
Loading…
Reference in a new issue