Skip to content
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

handle more connection parameters #20

Closed
wants to merge 3 commits into from
Closed

handle more connection parameters #20

wants to merge 3 commits into from

Conversation

ultrabug
Copy link

Hi Dan,

Would you please consider those commits ? They add connection parameters support for :

  • all newer pymongo ReadPreference flags as per [1]
  • use_greenlets flag for the gevent users
  • socket and connect timeouts (ms)

[1] http://api.mongodb.org/python/current/api/pymongo/index.html#pymongo.read_preferences.ReadPreference

Thank you :)

@@ -142,10 +149,13 @@ def key(suffix):
app.config[key('DBNAME')] = parsed['database']
app.config[key('READ_PREFERENCE')] = parsed['options'].get('read_preference')
app.config[key('AUTO_START_REQUEST')] = parsed['options'].get('auto_start_request', True)
app.config[key('USE_GREENLETS')] = parsed['options'].get('use_greenlets', False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in #15, we (the PyMongo maintainers and I) prefer not to expose internal details like use_greenlets.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, in PyMongo 2.4.2 we are starting to expose this. Not because it's useful to application developers though. It solves a problem with MasterSlaveConnection. In PyMongo 3.0 (whenever that happens) MasterSlaveConnection will go away, as well as this property.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a Flask app would never want to set use_greenlets True, since it's either running multithreaded (in which case setting use_greenlets would cause bugs) or under Gevent (which would call patch_thread and make use_greenlets unnecessary).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right indeed, this was something I noted back then when using gevent with threads. This can be ignored, thanks for the clarification guys.

@dcrosta
Copy link
Collaborator

dcrosta commented Jan 22, 2013

@ultrabug after consultation with the experts, I think the right path is to:

  1. Stop "copying" the read preference constants from PyMongo into Flask-PyMongo
  2. Remove validation from class PyMongo, or at least don't add any new validation

I'd be willing to accept a pull request or two which addressed those issues.

I'd also like to hear what your use case for using the timeouts is.

@ultrabug
Copy link
Author

I commented on the related diffs, as for the validation I also agree with you guys to rely on pymongo's direcly (I added those just to be compliant with what seemed to be your current policy on flask-pymongo).

@dcrosta : based on your final observations about the timeouts, I'll be glad to propose a new pull request to address all those matters at once.

Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants