idanmo / python-memcached-udp

A simple UDP Memcached client implementation written in Python.
Apache License 2.0
3 stars 2 forks source link

cannot get response data when content is too large #5

Open thinkycx opened 6 years ago

thinkycx commented 6 years ago

It seems that when the data is too large, we cannot get the response data. Actually, the data is in the memcached server but the python script cannot get it.

  1 #!/usr/bin/env python
  2 # coding=utf-8
  3 import memcached_udp
  4 payload = "B"*65400 + "A"
  5 client = memcached_udp.Client([('192.168.63.165', 11211)])
  6 client.set('key1', payload)
  7 r = client.get('key1')
  8 print r
  9 print 'done'

output: None done

idanmo commented 6 years ago

Hi,

I just created a branch with a fix for this issue. Before releasing a new version, do you mind validating if the handle-multi-packet-responses branch works for you?

Thanks!

thinkycx commented 6 years ago

Thanks for your reply! I have tested your branch but it did't work. TEST CODE:

#!/usr/bin/env python
# coding=utf-8
import time
import memcached_udp
for i in range(65534):
    if (i+1) %500 == 0 :
        payload = "A"*i
        print i
        client = memcached_udp.Client([('192.168.63.165', 11211)])
        client.set('key1', payload)
        time.sleep(3)
        r = client.get('key1')
        print r

OUTPUT

➜  python-memcached-udp.git (handle-multi-packet-responses)python test.py
499
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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