Invoke the application
(self, application)
| 127 | bytes_sent = 0 |
| 128 | |
| 129 | def run(self, application): |
| 130 | """Invoke the application""" |
| 131 | # Note to self: don't move the close()! Asynchronous servers shouldn't |
| 132 | # call close() from finish_response(), so if you close() anywhere but |
| 133 | # the double-error branch here, you'll break asynchronous servers by |
| 134 | # prematurely closing. Async servers must return from 'run()' without |
| 135 | # closing if there might still be output to iterate over. |
| 136 | try: |
| 137 | self.setup_environ() |
| 138 | self.result = application(self.environ, self.start_response) |
| 139 | self.finish_response() |
| 140 | except (ConnectionAbortedError, BrokenPipeError, ConnectionResetError): |
| 141 | # We expect the client to close the connection abruptly from time |
| 142 | # to time. |
| 143 | return |
| 144 | except: |
| 145 | try: |
| 146 | self.handle_error() |
| 147 | except: |
| 148 | # If we get an error handling an error, just give up already! |
| 149 | self.close() |
| 150 | raise # ...and let the actual server figure it out. |
| 151 | |
| 152 | |
| 153 | def setup_environ(self): |
no test coverage detected