uwsgi start params:
--socket 127.0.0.1:8081 --daemonize --enable-threads --threads 2 --processes 2
I setup my MongoClient ONE time:
self.mongo_client = MongoClient('mongodb://user:p...@host.mongolab.com:port/mydb')
self.db = self.mongo_client['mydb']
I try and save a json dict to mongo:
result = self.db.jobs.insert_one(job_dict)
It works via a unit test that executes the same code path to mongodb. However when I execute via cherrypy and uwsgi using an HTTP POST, I get this:
pymongo.errors.ServerSelectionTimeoutError: No servers found yet
Why am I seeing this behavior when run via cherrypy and uwsgi? Is this perhaps the new thread model in pymongo 3?
update:
if I run without uWSGI and nginx by using the cherrypy built-in server, the insert_one() works.
update 1/25 4:53pm EST:
After adding some debug in pymongo, it appears that topology._update_servers() knows that the server_type = 2 for server 'myserver-a.mongolab.com'. However server_description.known_servers() has the server_type = 0 for server 'myserver.mongolab.com'
This leads to the following stack trace:
result = self.db.jobs.insert_one(job_dict)
File "/usr/local/lib/python3.4/site-packages/pymongo/collection.py", line 466, in insert_one
with self._socket_for_writes() as sock_info:
File "/usr/local/lib/python3.4/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.4/site-packages/pymongo/mongo_client.py", line 663, in _get_socket
server = self._get_topology().select_server(selector)
File "/usr/local/lib/python3.4/site-packages/pymongo/topology.py", line 121, in select_server
address))
File "/usr/local/lib/python3.4/site-packages/pymongo/topology.py", line 97, in select_servers
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: No servers found yet
This is a sandbox instance on mongolab. I can ping both hosts from my linux box on AWS.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/7qX03P3_zKM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/34c14ca9-a3b9-450a-90ad-e84b23d4d603%40googlegroups.com.
nslookup myserver.mongolab.com
Server: 192.168.1.254
Address: 192.168.1.254#53
Non-authoritative answer:
myserver.mongolab.com canonical name = myserver-a.mongolab.com.
myserver-a.mongolab.com canonical name = h000000.mongolab.com.
h000000.mongolab.com canonical name = ec2-54-92-xxx-xxx.compute-1.amazonaws.com.
Address: 54.92.xxx-xxx
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/7qX03P3_zKM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/256b9195-c195-4ea9-9966-eb3aba16822c%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAKn4zXCnD1PkVdipMLayzUm%3DVjOXHHWqVuUjW4UF1-Ljhxw-uQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/7qX03P3_zKM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/64c5e7d6-c05b-45f7-bf37-43f5c89ade19%40googlegroups.com.