HTTPretty does not respect timeouts anymore
mariojonke opened this issue · comments
Since latest release (1.1.2) socket timeouts are not raised anymore.
The problem can be reproduced by the following test:
import requests
from threading import Event
from httpretty import httprettified
from httpretty import HTTPretty
@httprettified
def test_read_timeout():
event = Event()
uri = "http://example.com"
def my_callback(request, url, headers):
event.wait(10)
return 200, headers, "Received"
HTTPretty.register_uri(HTTPretty.GET, uri, body=my_callback)
requests.get(uri, timeout=(1, 0.1))
event.set()
The test should actually raise a TimeoutError but instead waits until my_callback
completes execution.
It seems that the problem is at httppretty/core.py#700, where joining the request callback thread with None
will wait infinitely until the callback finishes. So the socket.timeout
will actually never be raised.
Thanks @mariojonke for the report and the test case 🙏🏽
Fix in #431 cc @mariojonke
fixed on release 1.1.3