1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | # In a clean directory, run:
|
---|
4 | # xapian-tcpsrv --timeout=0 --port=8900 --writable bug
|
---|
5 |
|
---|
6 | import xapian
|
---|
7 |
|
---|
8 |
|
---|
9 | def test():
|
---|
10 | def replace_document(i):
|
---|
11 | slots = {
|
---|
12 | 'id': 1973816463L,
|
---|
13 | 'date': 4132511615L,
|
---|
14 | 'color': 1271831549L,
|
---|
15 | 'size': 962337316L,
|
---|
16 | }
|
---|
17 | doc = xapian.Document()
|
---|
18 | doc.set_data('"DATA %s"' % i)
|
---|
19 | doc.add_value(slots['id'], 'doc%s' % i)
|
---|
20 | doc.add_boolean_term('Qdoc%s' % i)
|
---|
21 | wd.replace_document('Qdoc%s' % i, doc) # Seems this must be a replace_document() for it to fail
|
---|
22 | wd.commit()
|
---|
23 |
|
---|
24 | wd = xapian.remote_open_writable('localhost', 8900, 0)
|
---|
25 | rd = xapian.remote_open('localhost', 8900, 0)
|
---|
26 | try:
|
---|
27 | wd.keep_alive()
|
---|
28 | rd.keep_alive()
|
---|
29 |
|
---|
30 | # WRITE END
|
---|
31 | replace_document(1)
|
---|
32 | # replace_document(2)
|
---|
33 | # replace_document(3)
|
---|
34 |
|
---|
35 | # READ END
|
---|
36 | rd.reopen()
|
---|
37 |
|
---|
38 | print '1:', rd.get_document(1).get_data()
|
---|
39 |
|
---|
40 | # WRITE END
|
---|
41 | replace_document(2)
|
---|
42 |
|
---|
43 | # READ END
|
---|
44 | rd.reopen()
|
---|
45 |
|
---|
46 | print '2:', rd.get_document(1).get_data() # This will throw EOF (most of the times)
|
---|
47 |
|
---|
48 | finally:
|
---|
49 | rd.close()
|
---|
50 | wd.close()
|
---|
51 |
|
---|
52 |
|
---|
53 | if __name__ == '__main__':
|
---|
54 | test()
|
---|