-
-
Save denik/588369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### traceback | |
Traceback (most recent call last): | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/gevent/greenlet.py", line 405, in run | |
result = self._run(*self.args, **self.kwargs) | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/collection.py", line 270, in insert | |
check_keys, safe, kwargs), safe) | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/connection.py", line 601, in _send_message | |
sock = self.__pool.socket() | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/connection.py", line 147, in socket | |
self.sock = (pid, self.socket_factory()) | |
File "/Users/newshour/code/python/chatterbox/lib/python2.6/site-packages/pymongo/connection.py", line 515, in __connect | |
raise AutoReconnect("could not connect to %r" % list(self.__nodes)) | |
AutoReconnect: could not connect to [('localhost', 27017)] | |
<Greenlet at 0x102610e20: <bound method Collection.insert of Collection(Database(Connection(None, None), u'test'), u'test2')>({'num': 31, '_id': ObjectId('4c978fcdc25f372d5e000)> failed with AutoReconnect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymongo | |
c = pymongo.Connection() | |
db = c.test | |
for i in xrange(1000): | |
db.test1.insert({'num': i}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# monkey patching should be done before anything else | |
from gevent import monkey | |
monkey.patch_all() | |
import pymongo | |
import gevent | |
c = pymongo.Connection() | |
test2 = c.db.test2 | |
jobs = [gevent.spawn(test2.insert, {'num': i}) for i in xrange(1000)] | |
gevent.joinall(jobs) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment