MCPcopy Index your code
hub / github.com/RustPython/RustPython / DummyPOP3Server

Class DummyPOP3Server

Lib/test/test_poplib.py:207–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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