Send any iterable data, then close self and the iterable Subclasses intended for use in asynchronous servers will want to redefine this method, such that it sets up callbacks in the event loop to iterate over the data, and to call 'self.close()' once the response is
(self)
| 172 | |
| 173 | |
| 174 | def finish_response(self): |
| 175 | """Send any iterable data, then close self and the iterable |
| 176 | |
| 177 | Subclasses intended for use in asynchronous servers will |
| 178 | want to redefine this method, such that it sets up callbacks |
| 179 | in the event loop to iterate over the data, and to call |
| 180 | 'self.close()' once the response is finished. |
| 181 | """ |
| 182 | try: |
| 183 | if not self.result_is_file() or not self.sendfile(): |
| 184 | for data in self.result: |
| 185 | self.write(data) |
| 186 | self.finish_content() |
| 187 | except: |
| 188 | # Call close() on the iterable returned by the WSGI application |
| 189 | # in case of an exception. |
| 190 | if hasattr(self.result, 'close'): |
| 191 | self.result.close() |
| 192 | raise |
| 193 | else: |
| 194 | # We only call close() when no exception is raised, because it |
| 195 | # will set status, result, headers, and environ fields to None. |
| 196 | # See bpo-29183 for more details. |
| 197 | self.close() |
| 198 | |
| 199 | |
| 200 | def get_scheme(self): |
no test coverage detected