def run(self):
try:<EOL><INDENT>handler = AdminMediaHandler(WSGIHandler())<EOL>if self.serve_static:<EOL><INDENT>handler = _patch_static_handler(handler)<EOL><DEDENT>server_address = (self.address, self.port)<EOL>httpd = StoppableWSGIServer(server_address, WSGIRequestHandler)<EOL>httpd.application = handler<EOL>self.started.set()<EOL><DEDENT>except WSGIServerException as err:<EOL><INDENT>self.error = err<EOL>self.started.set()<EOL>return<EOL><DEDENT>while not self._stopevent.isSet():<EOL><INDENT>httpd.handle_request()<EOL><DEDENT>
Sets up test server and loops over handling http requests.