Skip to content

Commit e28da6c

Browse files
committed
Custom timeouts and cert files - new builds
1 parent 9663081 commit e28da6c

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ auth = Auth(
7373
blocking=True/False, # Optional: True to enable user blocking
7474
readable_errors=True/False, # Optional: False to switch to numeric error codes translated in the README.md file
7575
attempts=6, # Optional: Number of attempts for initial MongoDB connection (default is 6).
76-
delay=10 # Optional: Delay in seconds between MongoDB initial connection attempts (default is 10 seconds).
76+
delay=10, # Optional: Delay in seconds between MongoDB initial connection attempts (default is 10 seconds).
77+
timeout=5000, # Optional: Timeout in ms for MongoDB connection (default is 5000 ms).
78+
certs=certifi.where() # Optional: Path to CA bundle for SSL verification (default is certifi's CA bundle)
7779
)
7880
```
7981
This code initializes the package.
87 Bytes
Binary file not shown.
134 Bytes
Binary file not shown.

src/easy_mongodb_auth_handler/auth.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Auth:
2222

2323
def __init__(self, mongo_uri, db_name, mail_info=None,
2424
blocking=True, readable_errors=True, attempts=6,
25-
delay=10):
25+
delay=10, timeout=5000, certs=certifi.where()):
2626
"""
2727
initializes the Auth class
2828
@@ -46,8 +46,9 @@ def __init__(self, mongo_uri, db_name, mail_info=None,
4646
while self.db is None and self.retry_count < self.max_retries:
4747
try:
4848
self.client = MongoClient(mongo_uri,
49-
serverSelectionTimeoutMS=5000,
50-
tlsCAFile=certifi.where())
49+
serverSelectionTimeoutMS=timeout,
50+
tlsCAFile=certs
51+
)
5152
self.db = self.client[db_name]
5253
except Exception:
5354
self.retry_count += 1

0 commit comments

Comments
 (0)