[Python] How can you disable the output of socketserver in Python?

Discussão em 'Python' iniciado por Stack, Abril 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have socketserver set up to run some unittests, and it's outputting its log to the console.

    Is there a way to disable this?

    Here's roughly the code I'm running:

    class TestServer(SocketServer.TCPServer):
    allow_reuse_address = True


    class ScraperExampleTest(unittest.TestCase):
    def setUp(self):
    # Due to requests not supporting the 'file' scheme, we are forced to run
    # our own server. See: https://github.com/kennethreitz/requests/issues/847
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = TestServer(('', PORT), Handler)
    httpd_thread = threading.Thread(target=httpd.serve_forever)
    httpd_thread.setDaemon(True)
    httpd_thread.start()

    Continue reading...

Compartilhe esta Página