Code Monkey home page Code Monkey logo

Comments (2)

pegler avatar pegler commented on May 13, 2024

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.

stephenemslie avatar stephenemslie commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.