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

Class DummyFTPServer

Lib/test/test_ftplib.py:279–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277
278
279class DummyFTPServer(asyncore.dispatcher, threading.Thread):
280
281 handler = DummyFTPHandler
282
283 def __init__(self, address, af=socket.AF_INET, encoding=DEFAULT_ENCODING):
284 threading.Thread.__init__(self)
285 asyncore.dispatcher.__init__(self)
286 self.daemon = True
287 self.create_socket(af, socket.SOCK_STREAM)
288 self.bind(address)
289 self.listen(5)
290 self.active = False
291 self.active_lock = threading.Lock()
292 self.host, self.port = self.socket.getsockname()[:2]
293 self.handler_instance = None
294 self.encoding = encoding
295
296 def start(self):
297 assert not self.active
298 self.__flag = threading.Event()
299 threading.Thread.start(self)
300 self.__flag.wait()
301
302 def run(self):
303 self.active = True
304 self.__flag.set()
305 while self.active and asyncore.socket_map:
306 self.active_lock.acquire()
307 asyncore.loop(timeout=0.1, count=1)
308 self.active_lock.release()
309 asyncore.close_all(ignore_all=True)
310
311 def stop(self):
312 assert self.active
313 self.active = False
314 self.join()
315
316 def handle_accepted(self, conn, addr):
317 self.handler_instance = self.handler(conn, encoding=self.encoding)
318
319 def handle_connect(self):
320 self.shutdown()
321 handle_read = handle_connect
322
323 def writable(self):
324 return 0
325
326 def handle_error(self):
327 default_error_handler()
328
329
330if ssl is not None:

Callers 2

setUpMethod · 0.85
setUpMethod · 0.85

Calls

no outgoing calls

Tested by 2

setUpMethod · 0.68
setUpMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…