The problem of communication php and python using memcached?

0 like 0 dislike
if there is a set of php memcache when you try to do to get such a key from python get:
>>> import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
/usr/bin/python2.6 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5]
>>> import memcache
>>> import binascii
>>> m=memcache.Client([''], debug=0)
>>> def php_hash(key):
... return (binascii.crc32(key) >> 16) & 0x7fff
>>> m.get((php_hash(mfd.php_nexttime), mfd.php_nexttime))
Traceback (most recent call last):
File ", line 1, in NameError: name 'mfd' is not defined
>>> m.get((php_hash('mfd.php_nexttime'), 'mfd.php_nexttime'))
Traceback (most recent call last):
File ", line 1, in File "/usr/lib/pymodules/python2.6/", line 779, in get
return self._get('get', key)
File "/usr/lib/pymodules/python2.6/", line 766, in _get
value = self._recv_value(server, flags, rlen)
File "/usr/lib/pymodules/python2.6/", line 915, in _recv_value
return val
UnboundLocalError: local variable 'val' referenced before assignment

Tired of googling can anyone faced?
by | 36 views

3 Answers

0 like 0 dislike
Probably will have to get you to the source Pitango customer and chopping everything that is associated with flags. The flags (768 and 300 for example) customers retain information about how they coded (serialized) data. cm
In your case the mfd VALUE.php_nexttime 768 10 flag is 768 and 10 — length of the response (10 bytes). Just do not quite understand why you have for the same key different flags (because there are both times the same value was??)
If you on both ends (php-python) will use the same methods of serialization, let's see what flag marks their PHP client, and make Python client on the same or use the text flag by default. Specifically hardly tell as there is just need in the code and poking them. (see the function _recv_value(self, server, flags, rlen) in the source client, you can write val = buf as an option for
else: val = buf#so!! self.debuglog("unknown flags on get: %x\" % flags)
0 like 0 dislike
Python probably trying deserializable value immediately breaks off — serializer php syntax is not familiar to him... the decision to push in Menkes json encoded value in Python to decode well, or any other "standard format"
0 like 0 dislike
Walked through the code library... first, Try memcache.debug=True and see what it writes to stderr.

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
6 answers
0 like 0 dislike
1 answer
asked Jun 4, 2019 by tuxx
0 like 0 dislike
1 answer
asked May 20, 2019 by McMike
110,608 questions
257,187 answers
40,796 users