mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get the IP addresses again when restarting the smartdevice driver.
This commit is contained in:
parent
82550e6ace
commit
6914cdec13
@ -71,6 +71,8 @@ class ConnectionListener (Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
queue_not_serviced_count = 0
|
queue_not_serviced_count = 0
|
||||||
device_socket = None
|
device_socket = None
|
||||||
|
get_all_ips(reinitialize=True)
|
||||||
|
|
||||||
while self.keep_running:
|
while self.keep_running:
|
||||||
try:
|
try:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
@ -14,7 +14,7 @@ _server = None
|
|||||||
|
|
||||||
_all_ip_addresses = dict()
|
_all_ip_addresses = dict()
|
||||||
|
|
||||||
class AllIpAddressesGetter (Thread):
|
class AllIpAddressesGetter(Thread):
|
||||||
|
|
||||||
def get_all_ips(self):
|
def get_all_ips(self):
|
||||||
''' Return a mapping of interface names to the configuration of the
|
''' Return a mapping of interface names to the configuration of the
|
||||||
@ -37,13 +37,20 @@ class AllIpAddressesGetter (Thread):
|
|||||||
def run(self):
|
def run(self):
|
||||||
global _all_ip_addresses
|
global _all_ip_addresses
|
||||||
# print 'sleeping'
|
# print 'sleeping'
|
||||||
# time.sleep(10)
|
# time.sleep(15)
|
||||||
# print 'slept'
|
# print 'slept'
|
||||||
_all_ip_addresses = self.get_all_ips()
|
_all_ip_addresses = self.get_all_ips()
|
||||||
|
|
||||||
AllIpAddressesGetter().start()
|
_ip_address_getter_thread = None
|
||||||
|
|
||||||
def get_all_ips():
|
def get_all_ips(reinitialize=False):
|
||||||
|
global _all_ip_addresses, _ip_address_getter_thread
|
||||||
|
if not _ip_address_getter_thread or (reinitialize and not
|
||||||
|
_ip_address_getter_thread.is_alive()):
|
||||||
|
_all_ip_addresses = dict()
|
||||||
|
_ip_address_getter_thread = AllIpAddressesGetter()
|
||||||
|
_ip_address_getter_thread.setDaemon(True)
|
||||||
|
_ip_address_getter_thread.start()
|
||||||
return _all_ip_addresses
|
return _all_ip_addresses
|
||||||
|
|
||||||
def _get_external_ip():
|
def _get_external_ip():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user