After some time looking at the mongodb documentation and the pymongo API, I am still no clearer on what route I take as the way forward (more confused now that when I started) . My problem concerns locks ... not so much that I have tested and found there to be major concurrency problems, but that I don't want to run into them after the fact.
I have a tkinter script with several functions, all of them need access to the same document collection, and most of them access the same single document within that collection.
client = MongoClient()
def 1 ():
glob_client = client['ALPHA']['A-Z']
#do work:
"""Also call subprocesses that use the same database document (glob_client) in another script.
There can be 3 -10 instances of this subprocess running, listening to various http streams in a while loop,
collecting data that can come in at 100's of times per second."""
def2 ():
glob_client = client['ALPHA']['A-Z']
...
def32 ():
glob_client = client['ALPHA']['A-Z']
And the called subprocess(in separate scripts), multiple instances possible:
client = MongoClient()
glob_client = client['ALPHA']['A-Z']
while True:
#do work with glob_client; updates, push, pull, reads,
So, would it be enough in this case to just use client.close() in every function?
def 1 ():
glob_client = client['ALPHA']['A-Z']
#do work
client.close()
Similarly in the while loops:
while True:
#do work with glob_client; updates, push, pull, reads,
Client.close()
Would that suffice, or should I be looking to shard in this case? Or should I just go back to SQL!
Mongodb 3.0.6 32-bit, pymongo 3.03, python 2.7.