##// END OF EJS Templates
zeroconf: use str instead of bytes when indexing `globals()`...
Matt Harbison -
r52893:c76c1c94 default
parent child Browse files
Show More
@@ -95,7 +95,7 from mercurial import pycompat
95
95
96 # hook for threads
96 # hook for threads
97
97
98 globals()[b'_GLOBAL_DONE'] = 0
98 globals()['_GLOBAL_DONE'] = 0
99
99
100 # Some timing constants
100 # Some timing constants
101
101
@@ -949,7 +949,7 class Engine(threading.Thread):
949 self.start()
949 self.start()
950
950
951 def run(self):
951 def run(self):
952 while not globals()[b'_GLOBAL_DONE']:
952 while not globals()['_GLOBAL_DONE']:
953 rs = self.getReaders()
953 rs = self.getReaders()
954 if len(rs) == 0:
954 if len(rs) == 0:
955 # No sockets to manage, but we wait for the timeout
955 # No sockets to manage, but we wait for the timeout
@@ -965,7 +965,7 class Engine(threading.Thread):
965 try:
965 try:
966 self.readers[sock].handle_read()
966 self.readers[sock].handle_read()
967 except Exception:
967 except Exception:
968 if not globals()[b'_GLOBAL_DONE']:
968 if not globals()['_GLOBAL_DONE']:
969 traceback.print_exc()
969 traceback.print_exc()
970 except Exception:
970 except Exception:
971 pass
971 pass
@@ -1045,7 +1045,7 class Reaper(threading.Thread):
1045 def run(self):
1045 def run(self):
1046 while True:
1046 while True:
1047 self.zeroconf.wait(10 * 1000)
1047 self.zeroconf.wait(10 * 1000)
1048 if globals()[b'_GLOBAL_DONE']:
1048 if globals()['_GLOBAL_DONE']:
1049 return
1049 return
1050 now = currentTimeMillis()
1050 now = currentTimeMillis()
1051 for record in self.zeroconf.cache.entries():
1051 for record in self.zeroconf.cache.entries():
@@ -1118,7 +1118,7 class ServiceBrowser(threading.Thread):
1118 now = currentTimeMillis()
1118 now = currentTimeMillis()
1119 if len(self.list) == 0 and self.nexttime > now:
1119 if len(self.list) == 0 and self.nexttime > now:
1120 self.zeroconf.wait(self.nexttime - now)
1120 self.zeroconf.wait(self.nexttime - now)
1121 if globals()[b'_GLOBAL_DONE'] or self.done:
1121 if globals()['_GLOBAL_DONE'] or self.done:
1122 return
1122 return
1123 now = currentTimeMillis()
1123 now = currentTimeMillis()
1124
1124
@@ -1408,7 +1408,7 class Zeroconf:
1408 def __init__(self, bindaddress=None):
1408 def __init__(self, bindaddress=None):
1409 """Creates an instance of the Zeroconf class, establishing
1409 """Creates an instance of the Zeroconf class, establishing
1410 multicast communications, listening and reaping threads."""
1410 multicast communications, listening and reaping threads."""
1411 globals()[b'_GLOBAL_DONE'] = 0
1411 globals()['_GLOBAL_DONE'] = 0
1412 if bindaddress is None:
1412 if bindaddress is None:
1413 self.intf = socket.gethostbyname(socket.gethostname())
1413 self.intf = socket.gethostbyname(socket.gethostname())
1414 else:
1414 else:
@@ -1848,8 +1848,8 class Zeroconf:
1848 def close(self):
1848 def close(self):
1849 """Ends the background threads, and prevent this instance from
1849 """Ends the background threads, and prevent this instance from
1850 servicing further queries."""
1850 servicing further queries."""
1851 if globals()[b'_GLOBAL_DONE'] == 0:
1851 if globals()['_GLOBAL_DONE'] == 0:
1852 globals()[b'_GLOBAL_DONE'] = 1
1852 globals()['_GLOBAL_DONE'] = 1
1853 self.notifyAll()
1853 self.notifyAll()
1854 self.engine.notify()
1854 self.engine.notify()
1855 self.unregisterAllServices()
1855 self.unregisterAllServices()
General Comments 0
You need to be logged in to leave comments. Login now