MCPcopy Index your code
hub / github.com/python/cpython / DummyPOP3Server

Class DummyPOP3Server

Lib/test/test_poplib.py:208–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206 self.handle_close()
207
208class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
209
210 handler = DummyPOP3Handler
211
212 def __init__(self, address, af=socket.AF_INET):
213 threading.Thread.__init__(self)
214 asyncore.dispatcher.__init__(self)
215 self.daemon = True
216 self.create_socket(af, socket.SOCK_STREAM)
217 self.bind(address)
218 self.listen(5)
219 self.active = False
220 self.active_lock = threading.Lock()
221 self.host, self.port = self.socket.getsockname()[:2]
222 self.handler_instance = None
223
224 def start(self):
225 assert not self.active
226 self.__flag = threading.Event()
227 threading.Thread.start(self)
228 self.__flag.wait()
229
230 def run(self):
231 self.active = True
232 self.__flag.set()
233 try:
234 while self.active and asyncore.socket_map:
235 with self.active_lock:
236 asyncore.loop(timeout=0.1, count=1)
237 finally:
238 asyncore.close_all(ignore_all=True)
239
240 def stop(self):
241 assert self.active
242 self.active = False
243 self.join()
244
245 def handle_accepted(self, conn, addr):
246 self.handler_instance = self.handler(conn)
247
248 def handle_connect(self):
249 self.close()
250 handle_read = handle_connect
251
252 def writable(self):
253 return 0
254
255 def handle_error(self):
256 raise
257
258
259class TestPOP3Class(TestCase):

Callers 3

setUpMethod · 0.85
setUpMethod · 0.85
setUpMethod · 0.85

Calls

no outgoing calls

Tested by 3

setUpMethod · 0.68
setUpMethod · 0.68
setUpMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…