-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-4703 MongoClient should default to connect=False on FaaS environments #1844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -803,7 +803,10 @@ def __init__( | |
if tz_aware is None: | ||
tz_aware = opts.get("tz_aware", False) | ||
if connect is None: | ||
connect = opts.get("connect", True) | ||
# Default to connect=True unless on a FaaS system, which might use fork. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest adding a versionchanged and updating the docstring for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
from pymongo.pool_options import _is_faas | ||
|
||
connect = opts.get("connect", not _is_faas()) | ||
keyword_opts["tz_aware"] = tz_aware | ||
keyword_opts["connect"] = connect | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import json | ||
import os | ||
import warnings | ||
|
||
from bson import has_c as has_bson_c | ||
from pymongo import MongoClient | ||
|
@@ -18,6 +19,9 @@ | |
ServerHeartbeatListener, | ||
) | ||
|
||
# Ensure there are no warnings raised in normal operation. | ||
warnings.simplefilter("error") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
|
||
open_connections = 0 | ||
heartbeat_count = 0 | ||
streaming_heartbeat_count = 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding
Function-as-a-service (FaaS) like AWS Lambda, Google Cloud Functions, and Microsoft Azure Functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done