Merge pull request #309 from seemethere/fix_write_error_loop
Fixes write_error loop from bail_out function
This commit is contained in:
commit
5a6fb679c9
|
@ -1,4 +1,5 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import traceback
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from inspect import isawaitable
|
from inspect import isawaitable
|
||||||
from signal import SIGINT, SIGTERM
|
from signal import SIGINT, SIGTERM
|
||||||
|
@ -189,9 +190,15 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
"Writing error failed, connection closed {}".format(e))
|
"Writing error failed, connection closed {}".format(e))
|
||||||
|
|
||||||
def bail_out(self, message):
|
def bail_out(self, message):
|
||||||
exception = ServerError(message)
|
if self.transport.is_closing():
|
||||||
self.write_error(exception)
|
log.error(
|
||||||
log.error(message)
|
"Connection closed before error was sent to user @ {}".format(
|
||||||
|
self.transport.get_extra_info('peername')))
|
||||||
|
log.debug('Error experienced:\n{}'.format(traceback.format_exc()))
|
||||||
|
else:
|
||||||
|
exception = ServerError(message)
|
||||||
|
self.write_error(exception)
|
||||||
|
log.error(message)
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.parser = None
|
self.parser = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user