I am developing a web and am using tornado server with motor. I use the generator to find the document from the collection. When the code is executed I get an error saying @gen is not defined. Motor, tornado.ioloop
and tornado.web
has been imported.
@gen.coroutine
def do_find_one():
document = yield db.users.find_one()
print (document)
One more thing is the web server could not be closed using Ctrl+C. I have to close the terminal every time and then start from beginning. Is there a way to stop the service in the terminal itself.
You should also import gen
to use it:
from tornado import gen
Python names are very straghtforward. You should either define a variable in your module or import it explicitly (or implicitly with from foo import *
while it's not a recommended way).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With