Skip to content

Instantly share code, notes, and snippets.

@denik
Forked from eyeseast/bad.py
Created September 20, 2010 18:22
Show Gist options
  • Save denik/588369 to your computer and use it in GitHub Desktop.
Save denik/588369 to your computer and use it in GitHub Desktop.
### 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
import pymongo
c = pymongo.Connection()
db = c.test
for i in xrange(1000):
db.test1.insert({'num': i})
# 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