How to use the pymemcache.exceptions.MemcacheServerError function in pymemcache

To help you get started, we’ve selected a few pymemcache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DataDog / dd-trace-py / tests / contrib / pymemcache / test_client.py View on Github external
def test_set_server_error(self):
        client = self.make_client([b'SERVER_ERROR some message\r\n'])

        def _set():
            client.set(b'key', b'value', noreply=False)

        pytest.raises(MemcacheServerError, _set)

        spans = self.check_spans(1, ['set'], ['set key'])
        self.assertEqual(spans[0].error, 1)
github pinterest / pymemcache / pymemcache / client / base.py View on Github external
def _raise_errors(self, line, name):
        if line.startswith(b'ERROR'):
            raise MemcacheUnknownCommandError(name)

        if line.startswith(b'CLIENT_ERROR'):
            error = line[line.find(b' ') + 1:]
            raise MemcacheClientError(error)

        if line.startswith(b'SERVER_ERROR'):
            error = line[line.find(b' ') + 1:]
            raise MemcacheServerError(error)
github DataDog / dd-trace-py / ddtrace / contrib / pymemcache / client.py View on Github external
# try to set relevant tags, catch any exceptions so we don't mess
            # with the application
            try:
                span.set_tags(p.tags)
                vals = _get_query_string(args)
                query = '{}{}{}'.format(method_name, ' ' if vals else '', vals)
                span.set_tag(memcachedx.QUERY, query)
            except Exception:
                log.debug('Error setting relevant pymemcache tags')

            try:
                return method(*args, **kwargs)
            except (
                MemcacheClientError,
                MemcacheServerError,
                MemcacheUnknownCommandError,
                MemcacheUnknownError,
                MemcacheIllegalInputError,
            ):
                (typ, val, tb) = sys.exc_info()
                span.set_exc_info(typ, val, tb)
                reraise(typ, val, tb)