Python SDK, bucket operations synchronous or no?

My understanding from the documentation is that using a bucket connection in the Python SDK should provide synchronous operations, however that’s not the behavior I’m seeing:

def get_total_docs(cluster, cbbucket):
    i = 0
    result = q_alldocs(cluster, cbbucket)
    for doc in result:
        i += 1
    print('%s total documents' % (i))

def create_empty_doc(cluster, cbbucket):
    bucket, collection = cbconnect_collection(cluster, cbbucket)
    new_uuid = str(uuid.uuid4())
    collection.upsert(new_uuid, {})
    return(new_uuid)

get_total_docs(cluster, cbbucket)
create_empty_doc(cluster, cbbucket)
get_total_docs(cluster, cbbucket)

results in:

[root@centos ~]#  /root/myprog.py 
2224 total documents
2224 total documents
[root@centos ~]#  /root/myprog.py 
2225 total documents
2225 total documents

Can somebody clear up for me why I’m not seeing synchronous behavior and a possible solution to achieve synchronous behavior?

Python SDK 3.0.0
CB Community 6.0.0

Thanks

@fwdalrymple can you pls provide the complete script? how is the connection established in cbconnect_collection?