Comments (2)
Like I said earlier, with an unmodified version of HTTPretty, it hangs in the _true_sendall
method. By modifying it to be as follows, the method returns:
def _true_sendall(self, data, *args, **kw):
self.truesock.connect(self._address)
self.truesock.sendall(data, *args, **kw)
_d = self.truesock.recv(16)
self.fd.seek(0)
self.fd.write(_d)
while _d:
if len(_d) < 16:
break
_d = self.truesock.recv(16)
self.fd.write(_d)
self.fd.seek(0)
self.truesock.close()
After disabling cached sessions in my django settings, I received this trace from the HTTPretty debug method when trying to access memcached while HTTPretty is enabled. memcache.py is http://pypi.python.org/pypi/python-memcached/
...
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 53, in add
return self._cache.add(key, value, self._get_memcache_timeout(timeout))
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/memcache.py", line 506, in add
return self._set("add", key, val, time, min_compress_len)
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/memcache.py", line 802, in _set
return _unsafe_set()
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/memcache.py", line 795, in _unsafe_set
return(server.expect("STORED") == "STORED")
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/memcache.py", line 1136, in expect
line = self.readline()
File "/home/pegler/environments/site/local/lib/python2.7/site-packages/memcache.py", line 1125, in readline
data = recv(4096)
File "/home/pegler/environments/site/src/httpretty/httpretty/__init__.py", line 319, in debug
lines = map(utf8, traceback.format_stack(frame))
from httpretty.
I'm seeing the same behaviour with pymongo. In my case it's blocking on _d = self.truesock.recv(16)
inside the while loop. Presumably this is down to the Mongo wire protocol not returning anything at that point, and there doesn't appear to be a timeout on the socket.
ipdb> print self.truesock.gettimeout()
None
A workaround is to set a timeout on self.truesock.
ipdb> self.truesock.settimeout(1)
ipdb> self.truesock.recv(16)
*** timeout: timed out
Or globally in your tests:
import socket
socket.setdefaulttimeout(1)
from httpretty.
Related Issues (20)
- 1.1.4: pytest is failing because missing `context` fixture HOT 2
- Record/Replay feature returns incorrect HTTP status code HOT 1
- ConnectionError when making multiple requests using a session on Windows HOT 1
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
- Emulate server down then coming online HOT 1
- Incorrect examples in documentation (contextmanager) HOT 2
- 1.1.4: pytest is failing because missing `context` and `port` fixtures and some pytest warnings HOT 6
- httpretty.errors.UnmockedError: Failed to socket.setblocking because because a real socket does not exist HOT 1
- 1.1.4: sphinx warnings `reference target not found`
- Typing error when using callback as body
- State of project HOT 1
- test_httpretty_should_handle_paths_starting_with_two_slashes needs update HOT 1
- 1.1.4: Tests are failing on s390x because of "did not run within two miliseconds" HOT 1
- Document global allow_net_connect flag HOT 1
- Request body isn't decoded when client specifies its charset
- Link headers Example does not work
- Reset should blank latest_requests? HOT 1
- FakeSockFile: `'super' object has no attribute 'flush'` HOT 1
- urllib3.contrib.pyopenssl is being deprecated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpretty.