Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work.
(self)
| 974 | to install it. |
| 975 | """ |
| 976 | def handle(self): |
| 977 | """ |
| 978 | Handle a request. |
| 979 | |
| 980 | Each request is expected to be a 4-byte length, packed using |
| 981 | struct.pack(">L", n), followed by the config file. |
| 982 | Uses fileConfig() to do the grunt work. |
| 983 | """ |
| 984 | try: |
| 985 | conn = self.connection |
| 986 | chunk = conn.recv(4) |
| 987 | if len(chunk) == 4: |
| 988 | slen = struct.unpack(">L", chunk)[0] |
| 989 | chunk = self.connection.recv(slen) |
| 990 | while len(chunk) < slen: |
| 991 | chunk = chunk + conn.recv(slen - len(chunk)) |
| 992 | if self.server.verify is not None: |
| 993 | chunk = self.server.verify(chunk) |
| 994 | if chunk is not None: # verified, can process |
| 995 | chunk = chunk.decode("utf-8") |
| 996 | try: |
| 997 | import json |
| 998 | d =json.loads(chunk) |
| 999 | assert isinstance(d, dict) |
| 1000 | dictConfig(d) |
| 1001 | except Exception: |
| 1002 | #Apply new configuration. |
| 1003 | |
| 1004 | file = io.StringIO(chunk) |
| 1005 | try: |
| 1006 | fileConfig(file) |
| 1007 | except Exception: |
| 1008 | traceback.print_exc() |
| 1009 | if self.server.ready: |
| 1010 | self.server.ready.set() |
| 1011 | except OSError as e: |
| 1012 | if e.errno != RESET_ERROR: |
| 1013 | raise |
| 1014 | |
| 1015 | class ConfigSocketReceiver(ThreadingTCPServer): |
| 1016 | """ |
nothing calls this directly
no test coverage detected