equal
deleted
inserted
replaced
1 from __future__ import print_function |
1 from __future__ import absolute_import, print_function |
2 |
2 |
3 """ Multicast DNS Service Discovery for Python, v0.12 |
3 """ Multicast DNS Service Discovery for Python, v0.12 |
4 Copyright (C) 2003, Paul Scott-Murphy |
4 Copyright (C) 2003, Paul Scott-Murphy |
5 |
5 |
6 This module provides a framework for the use of DNS Service Discovery |
6 This module provides a framework for the use of DNS Service Discovery |
78 |
78 |
79 __author__ = "Paul Scott-Murphy" |
79 __author__ = "Paul Scott-Murphy" |
80 __email__ = "paul at scott dash murphy dot com" |
80 __email__ = "paul at scott dash murphy dot com" |
81 __version__ = "0.12" |
81 __version__ = "0.12" |
82 |
82 |
|
83 import select |
|
84 import socket |
83 import string |
85 import string |
|
86 import struct |
|
87 import threading |
84 import time |
88 import time |
85 import struct |
|
86 import socket |
|
87 import threading |
|
88 import select |
|
89 import traceback |
89 import traceback |
90 |
90 |
91 __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"] |
91 __all__ = ["Zeroconf", "ServiceInfo", "ServiceBrowser"] |
92 |
92 |
93 # hook for threads |
93 # hook for threads |
761 is done.""" |
761 is done.""" |
762 if not self.finished: |
762 if not self.finished: |
763 self.finished = 1 |
763 self.finished = 1 |
764 for question in self.questions: |
764 for question in self.questions: |
765 self.writeQuestion(question) |
765 self.writeQuestion(question) |
766 for answer, time in self.answers: |
766 for answer, time_ in self.answers: |
767 self.writeRecord(answer, time) |
767 self.writeRecord(answer, time_) |
768 for authority in self.authorities: |
768 for authority in self.authorities: |
769 self.writeRecord(authority, 0) |
769 self.writeRecord(authority, 0) |
770 for additional in self.additionals: |
770 for additional in self.additionals: |
771 self.writeRecord(additional, 0) |
771 self.writeRecord(additional, 0) |
772 |
772 |
866 self.condition.wait(self.timeout) |
866 self.condition.wait(self.timeout) |
867 self.condition.release() |
867 self.condition.release() |
868 else: |
868 else: |
869 try: |
869 try: |
870 rr, wr, er = select.select(rs, [], [], self.timeout) |
870 rr, wr, er = select.select(rs, [], [], self.timeout) |
871 for socket in rr: |
871 for sock in rr: |
872 try: |
872 try: |
873 self.readers[socket].handle_read() |
873 self.readers[sock].handle_read() |
874 except Exception: |
874 except Exception: |
875 if not globals()['_GLOBAL_DONE']: |
875 if not globals()['_GLOBAL_DONE']: |
876 traceback.print_exc() |
876 traceback.print_exc() |
877 except Exception: |
877 except Exception: |
878 pass |
878 pass |