In [1]:
from tornado import gen
from tornado.ioloop import IOLoop
from motor import MotorClient

In [2]:
conn = MotorClient(host='128.199.219.106')
db = conn.twitter

In [3]:
@gen.coroutine
def test():
    cursor = db.tweets.find()
    print((yield cursor.find_one()))
    
IOLoop.instance().run_sync(test)


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-577ad7e8a295> in <module>()
      4     print((yield cursor.find_one()))
      5 
----> 6 IOLoop.instance().run_sync(test)

/Users/laisky/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tornado/ioloop.py in run_sync(self, func, timeout)
    411         if timeout is not None:
    412             timeout_handle = self.add_timeout(self.time() + timeout, self.stop)
--> 413         self.start()
    414         if timeout is not None:
    415             self.remove_timeout(timeout_handle)

/Users/laisky/.pyenv/versions/3.4.1/lib/python3.4/site-packages/zmq/eventloop/ioloop.py in start(self)
    149     def start(self):
    150         try:
--> 151             super(ZMQIOLoop, self).start()
    152         except ZMQError as e:
    153             if e.errno == ETERM:

/Users/laisky/.pyenv/versions/3.4.1/lib/python3.4/site-packages/tornado/ioloop.py in start(self)
    702     def start(self):
    703         if self._running:
--> 704             raise RuntimeError("IOLoop is already running")
    705         self._setup_logging()
    706         if self._stopped:

RuntimeError: IOLoop is already running