00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 """Simple script to help test auto-reconnection."""
00016
00017 import sys
00018 import threading
00019 import time
00020 sys.path[0:0] = [""]
00021
00022 from pymongo.errors import AutoReconnect
00023 from pymongo.connection import Connection
00024
00025 db = Connection.paired(("localhost", 27018)).test
00026 db.test.remove({})
00027
00028 class Something(threading.Thread):
00029 def run(self):
00030 while True:
00031 time.sleep(1)
00032 try:
00033 id = db.test.save({"x": 1}, safe=True)
00034 assert db.test.find_one(id)["x"] == 1
00035 db.test.remove(id)
00036 db.connection.end_request()
00037 print "Y"
00038 except AutoReconnect, e:
00039 print e
00040 print "N"
00041
00042 for _ in range(1):
00043 t = Something()
00044 t.start()
00045 time.sleep(1)