Changeset 37:16c62607bcd6
- Timestamp:
- 06/18/06 09:04:04
(2 years ago)
- Author:
- Allan Saddi <allan@saddi.com>
- branch:
- default
- convert_revision:
- svn:46762da8-4eb7-0310-94e9-d918b60927c8/flup/trunk@2015
- Message:
Stop ignoring EPIPE exceptions.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r36 |
r37 |
|
| | 1 | 2006-06-18 Allan Saddi <asaddi@europa.saddi.net> |
|---|
| | 2 | |
|---|
| | 3 | * Stop ignoring EPIPE exceptions, as this is probably the |
|---|
| | 4 | wrong thing to do. (Application is unaware of disconnected |
|---|
| | 5 | clients and the CPU spins when sending large files to a |
|---|
| | 6 | disconnected client.) Thanks to Ivan Sagalaev for bringing |
|---|
| | 7 | this to my attention. |
|---|
| | 8 | |
|---|
| | 9 | NB: Existing applications that use the flup servers may begin |
|---|
| | 10 | seeing socket.error exceptions... |
|---|
| | 11 | |
|---|
| 1 | 12 | 2006-05-18 Allan Saddi <asaddi@kalahari.flup.org> |
|---|
| 2 | 13 | |
|---|
| r35 |
r37 |
|
| 298 | 298 | sent = sock.send(data) |
|---|
| 299 | 299 | except socket.error, e: |
|---|
| 300 | | if e[0] == errno.EPIPE: |
|---|
| 301 | | return # Don't bother raising an exception. Just ignore. |
|---|
| 302 | | elif e[0] == errno.EAGAIN: |
|---|
| | 300 | if e[0] == errno.EAGAIN: |
|---|
| 303 | 301 | select.select([], [sock], []) |
|---|
| 304 | 302 | continue |
|---|
| … | … | |
| 898 | 896 | self._appLock.acquire() |
|---|
| 899 | 897 | try: |
|---|
| 900 | | result = self.application(environ, start_response) |
|---|
| 901 | 898 | try: |
|---|
| 902 | | for data in result: |
|---|
| 903 | | if data: |
|---|
| 904 | | write(data) |
|---|
| 905 | | if not headers_sent: |
|---|
| 906 | | write('') # in case body was empty |
|---|
| 907 | | finally: |
|---|
| 908 | | if hasattr(result, 'close'): |
|---|
| 909 | | result.close() |
|---|
| | 899 | result = self.application(environ, start_response) |
|---|
| | 900 | try: |
|---|
| | 901 | for data in result: |
|---|
| | 902 | if data: |
|---|
| | 903 | write(data) |
|---|
| | 904 | if not headers_sent: |
|---|
| | 905 | write('') # in case body was empty |
|---|
| | 906 | finally: |
|---|
| | 907 | if hasattr(result, 'close'): |
|---|
| | 908 | result.close() |
|---|
| | 909 | except socket.error, e: |
|---|
| | 910 | if e[0] != errno.EPIPE: |
|---|
| | 911 | raise # Don't let EPIPE propagate beyond server |
|---|
| 910 | 912 | finally: |
|---|
| 911 | 913 | if not self.multithreaded: |
|---|
| r36 |
r37 |
|
| 507 | 507 | sent = sock.send(data) |
|---|
| 508 | 508 | except socket.error, e: |
|---|
| 509 | | if e[0] == errno.EPIPE: |
|---|
| 510 | | return # Don't bother raising an exception. Just ignore. |
|---|
| 511 | | elif e[0] == errno.EAGAIN: |
|---|
| | 509 | if e[0] == errno.EAGAIN: |
|---|
| 512 | 510 | select.select([], [sock], []) |
|---|
| 513 | 511 | continue |
|---|
| … | … | |
| 1110 | 1108 | self._appLock.acquire() |
|---|
| 1111 | 1109 | try: |
|---|
| 1112 | | result = self.application(environ, start_response) |
|---|
| 1113 | 1110 | try: |
|---|
| 1114 | | for data in result: |
|---|
| 1115 | | if data: |
|---|
| 1116 | | write(data) |
|---|
| 1117 | | if not headers_sent: |
|---|
| 1118 | | write('') # in case body was empty |
|---|
| 1119 | | finally: |
|---|
| 1120 | | if hasattr(result, 'close'): |
|---|
| 1121 | | result.close() |
|---|
| | 1111 | result = self.application(environ, start_response) |
|---|
| | 1112 | try: |
|---|
| | 1113 | for data in result: |
|---|
| | 1114 | if data: |
|---|
| | 1115 | write(data) |
|---|
| | 1116 | if not headers_sent: |
|---|
| | 1117 | write('') # in case body was empty |
|---|
| | 1118 | finally: |
|---|
| | 1119 | if hasattr(result, 'close'): |
|---|
| | 1120 | result.close() |
|---|
| | 1121 | except socket.error, e: |
|---|
| | 1122 | if e[0] != errno.EPIPE: |
|---|
| | 1123 | raise # Don't let EPIPE propagate beyond server |
|---|
| 1122 | 1124 | finally: |
|---|
| 1123 | 1125 | if not self.multithreaded: |
|---|
| r32 |
r37 |
|
| 388 | 388 | s += '%s: %s\r\n' % header |
|---|
| 389 | 389 | s += '\r\n' |
|---|
| 390 | | try: |
|---|
| 391 | | request.stdout.write(s) |
|---|
| 392 | | except socket.error, e: |
|---|
| 393 | | if e[0] != errno.EPIPE: |
|---|
| 394 | | raise |
|---|
| 395 | | |
|---|
| 396 | | try: |
|---|
| 397 | | request.stdout.write(data) |
|---|
| 398 | | request.stdout.flush() |
|---|
| 399 | | except socket.error, e: |
|---|
| 400 | | if e[0] != errno.EPIPE: |
|---|
| 401 | | raise |
|---|
| | 390 | request.stdout.write(s) |
|---|
| | 391 | |
|---|
| | 392 | request.stdout.write(data) |
|---|
| | 393 | request.stdout.flush() |
|---|
| 402 | 394 | |
|---|
| 403 | 395 | def start_response(status, response_headers, exc_info=None): |
|---|
| … | … | |
| 428 | 420 | self._appLock.acquire() |
|---|
| 429 | 421 | try: |
|---|
| 430 | | result = self.application(environ, start_response) |
|---|
| 431 | 422 | try: |
|---|
| 432 | | for data in result: |
|---|
| 433 | | if data: |
|---|
| 434 | | write(data) |
|---|
| 435 | | if not headers_sent: |
|---|
| 436 | | write('') # in case body was empty |
|---|
| 437 | | finally: |
|---|
| 438 | | if hasattr(result, 'close'): |
|---|
| 439 | | result.close() |
|---|
| | 423 | result = self.application(environ, start_response) |
|---|
| | 424 | try: |
|---|
| | 425 | for data in result: |
|---|
| | 426 | if data: |
|---|
| | 427 | write(data) |
|---|
| | 428 | if not headers_sent: |
|---|
| | 429 | write('') # in case body was empty |
|---|
| | 430 | finally: |
|---|
| | 431 | if hasattr(result, 'close'): |
|---|
| | 432 | result.close() |
|---|
| | 433 | except socket.error, e: |
|---|
| | 434 | if e[0] != errno.EPIPE: |
|---|
| | 435 | raise # Don't let EPIPE propagate beyond server |
|---|
| 440 | 436 | finally: |
|---|
| 441 | 437 | if not self.multithreaded: |
|---|