Giter Club home page Giter Club logo

Comments (8)

hut8 avatar hut8 commented on June 30, 2024 2

@dkiser Out of curiosity, what app server are you using? I am using uwsgi. I just spent like two hours with a bug that I think is the same. Mine never throws an exception but instead just hangs, and this is what I get in the logs.

announcing my loyalty to the Emperor...
/srv/venv/lib/python3.4/site-packages/pymongo/topology.py:74: UserWarning: MongoClient opened before fork. Create MongoClient with connect=False, or create client after forking. See PyMongo's documentation for details: http://api.mongodb.org/python/current/faq.html#using-pymongo-with-multiprocessing>
  "MongoClient opened before fork. Create MongoClient "
[pid: 15145|app: 0|req: 1/2]  1.2.3.4 () {46 vars in 753 bytes} [Sun Jan 24 01:54:21 2016] GET /stats => generated 39 bytes in 30023 msecs (HTTP/1.1 500) 2 headers in 90 bytes (1 switches on core 0)

There's a timeout at 30 seconds. I can connect just fine using exactly the same stack/virtualenv (minus the app server of course) using a Flask-Script shell (https://flask-script.readthedocs.org/en/latest/#shell).

My solution was a one line fix; just add lazy-apps = true to my uwsgi INI file. That makes the workers fork then load the application.

from flask-pymongo.

hbldh avatar hbldh commented on June 30, 2024

@dkiser I don't think detection of >1 cores/threads is enough to handle this; I think that the PyMongo crowd would have implemented that instead of adding warnings in the api documentation (https://api.mongodb.org/python/3.1/faq.html#multiprocessing). Seems to me like adding a configuration option for this would be a better way to go.

from flask-pymongo.

dkiser avatar dkiser commented on June 30, 2024

@hbldh sounds good to me.

from flask-pymongo.

hbldh avatar hbldh commented on June 30, 2024

@dkiser Tests didn't pass on Travis at first, but when I added MONGO_CONNECT=False to all test cases it did.

@ranman Might be that this setting is required for correct handling of PyMongo 3.1 on Travis CI?

from flask-pymongo.

sibelius avatar sibelius commented on June 30, 2024

any progress on this?

from flask-pymongo.

dkiser avatar dkiser commented on June 30, 2024

@hut8 its been almost 3 months, so that is about 10 tech years ;) I believe I was using the same setup with uwsgi, but it failed immediately for me. We ended up just downgrading to pymong 2.8 in our Docker containers in the meantime.

from flask-pymongo.

hbldh avatar hbldh commented on June 30, 2024

@hut8 @dkiser I have been using gunicorn and also CherryPy web server, both of them most often as reverse proxy web servers.
I am using my fork since I sent my pull request, #67, and have not encountered ant problems yet.

A new pull request, #71, has been created with the same intent as this one, so I would not say that this issue is dead ...

from flask-pymongo.

ranman avatar ranman commented on June 30, 2024

I'll merge #67 after some docs updates

On Sun, Jan 24, 2016 at 2:18 PM, Henrik Blidh [email protected]
wrote:

@hut8 https://github.com/hut8 @dkiser https://github.com/dkiser I
have been using gunicorn http://gunicorn.org/ and also CherryPy
http://www.cherrypy.org/ web server, both of them most often as reverse
proxy web servers.
I am using my fork since I sent my pull request, #67
#67, and have not
encountered ant problems yet.

A new pull request, #71 #71,
has been created with the same intent as this one, so I would not say that
this issue is dead ...


Reply to this email directly or view it on GitHub
#66 (comment)
.

from flask-pymongo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.