Open mike-hart opened 7 years ago
EDIT: works with version < 6.x
Quick workaround to this bug:
from raven.transport.twisted import TwistedHTTPTransport
class FixedTwistedHTTPTransport(TwistedHTTPTransport):
def __init__(self, parsed_url, *args, **kwargs):
super().__init__(parsed_url, *args, **kwargs)
# twisted wants bytes
if isinstance(self._url, str):
self._url = str.encode(self._url)
client = Client(dsn=RAVEN_DSN, transport=FixedTwistedHTTPTransport)
Unless I'm missing something very important, self._url
is not something used anywhere other than the tests. This change results in a hang as the attempt to log an error results in an error which results in an attempt to log an error, which results in... etc. This causes the process to hang for an extended period at 100% CPU.
The only way I found to fix this was to do the encode of the url inside the send_async
method, basically copying the bulk of the implementation.
You are right. I didn't notice that you are talking about 6.x version. I'm using v5.x. The only way is to overload send_async
or Agent.request
.
Fix for raven==6.5.0:
class FixTwistedHTTPTransport(TwistedHTTPTransport):
url_encode = 'utf-8'
def async_send(self, url, data, headers, success_cb, failure_cb):
b_url = url.encode(url_encode)
return super().async_send(b_url, data, headers, success_cb, failure_cb)
client = raven.Client(dsn=dsn, transport=FixTwistedHTTPTransport)
More code required below for a twisted eventloop, sorry, this is ripped from a larger project.
if the DSN is a string then we get:
but if the DSN is bytes then we have: