(self, *args, **options)
| 119 | self.inner_run(None, **options) |
| 120 | |
| 121 | def inner_run(self, *args, **options): |
| 122 | # If an exception was silenced in ManagementUtility.execute in order |
| 123 | # to be raised in the child process, raise it now. |
| 124 | autoreload.raise_last_exception() |
| 125 | |
| 126 | threading = options["use_threading"] |
| 127 | # 'shutdown_message' is a stealth option. |
| 128 | shutdown_message = options.get("shutdown_message", "") |
| 129 | |
| 130 | if not options["skip_checks"]: |
| 131 | self.stdout.write("Performing system checks...\n\n") |
| 132 | check_kwargs = super().get_check_kwargs(options) |
| 133 | check_kwargs["display_num_errors"] = True |
| 134 | self.check(**check_kwargs) |
| 135 | # Need to check migrations here, so can't use the |
| 136 | # requires_migrations_check attribute. |
| 137 | self.check_migrations() |
| 138 | # Close all connections opened during migration checking. |
| 139 | for conn in connections.all(initialized_only=True): |
| 140 | conn.close() |
| 141 | |
| 142 | try: |
| 143 | handler = self.get_handler(*args, **options) |
| 144 | run( |
| 145 | self.addr, |
| 146 | int(self.port), |
| 147 | handler, |
| 148 | ipv6=self.use_ipv6, |
| 149 | threading=threading, |
| 150 | on_bind=self.on_bind, |
| 151 | server_cls=self.server_cls, |
| 152 | ) |
| 153 | except OSError as e: |
| 154 | # Use helpful error messages instead of ugly tracebacks. |
| 155 | ERRORS = { |
| 156 | errno.EACCES: "You don't have permission to access that port.", |
| 157 | errno.EADDRINUSE: "That port is already in use.", |
| 158 | errno.EADDRNOTAVAIL: "That IP address can't be assigned to.", |
| 159 | } |
| 160 | try: |
| 161 | error_text = ERRORS[e.errno] |
| 162 | except KeyError: |
| 163 | error_text = e |
| 164 | self.stderr.write("Error: %s" % error_text) |
| 165 | # Need to use an OS exit because sys.exit doesn't work in a thread |
| 166 | os._exit(1) |
| 167 | except KeyboardInterrupt: |
| 168 | if shutdown_message: |
| 169 | self.stdout.write(shutdown_message) |
| 170 | sys.exit(0) |
| 171 | |
| 172 | def on_bind(self, server_port): |
| 173 | quit_command = "CTRL-BREAK" if sys.platform == "win32" else "CONTROL-C" |
no test coverage detected