I'm trying to connect to mongodb from within a python program that uses mpi. The program below segfaults when using MPI:
$ srun -n 1 python -m mpi4py.futures mongo_mpi.py
Any ideas? Thanks, Ralph
1 from mpi4py import MPI
2 from mpi4py.futures import MPIPoolExecutor
3
4 from pymongo import MongoClient
5
6 import string
7 import random
8
9
10 def main():
11
12 rank = MPI.COMM_WORLD.Get_rank()
13 print(f"rank = {rank}")
14
15 rand = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(5))
16
17 client = MongoClient("dbserver.host", username="user", password="pass")18 db = client.get_database()
19 db.test_analysis.insert_one({rand: 'says hello'})
20 client.close()
21
22 if _name_ == "_main_":
23 main()