"yielded unknown object None" Error on connect
jslootweg opened this issue · 3 comments
I was just trying out the demo's I get the following error in both when the code attempts to open a connection
File "/Library/Python/2.7/site-packages/tornado_mysql/connections.py", line 820, in connect
2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e))
tornado_mysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'databaseserver' (yielded unknown object None)")
I am running on Yosemite with Python 2.7. MySQL server is running on a remote VM. I can confirm this machine will accept remote connections, I have tested this using the blocking MySQL tornado library.
Python 2.7 and OperationalError hides real traceback.
Could you try again with Python 3.4?
Or could you try with this modification to connections.py?
- if isinstance(e, err.MySQLError):
- raise
- raise OperationalError(
- 2003, "Can't connect to MySQL server on %r (%s)" % (self.host, e))
+ raise
OK this is the stack trace which results from making that mod.
Traceback (most recent call last):
File "/Users/james/Desktop/pymysqltest/example.py", line 29, in <module>
ioloop.IOLoop.current().run_sync(main)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/ioloop.py", line 365, in run_sync
return future_cell[0].result()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/concurrent.py", line 129, in result
raise_exc_info(self.__exc_info)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/stack_context.py", line 239, in wrapped
callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 551, in inner
self.set_result(key, result)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 480, in set_result
self.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 508, in run
yielded = self.gen.throw(*exc_info)
File "/Users/james/Desktop/pymysqltest/example.py", line 18, in main
conn = yield tornado_mysql.connect(host='databaseserver', port=3306, user='redacted', passwd='redacted', db='redacted')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 500, in run
next = self.yield_point.get_result()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 402, in get_result
return self.runner.pop_result(self.key).result()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/concurrent.py", line 129, in result
raise_exc_info(self.__exc_info)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/stack_context.py", line 263, in _nested
yield vars
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/stack_context.py", line 236, in wrapped
callback(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 551, in inner
self.set_result(key, result)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 480, in set_result
self.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 508, in run
yielded = self.gen.throw(*exc_info)
File "/Library/Python/2.7/site-packages/tornado_mysql/__init__.py", line 88, in connect
yield conn.connect()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 500, in run
next = self.yield_point.get_result()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 402, in get_result
return self.runner.pop_result(self.key).result()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/concurrent.py", line 129, in result
raise_exc_info(self.__exc_info)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 228, in wrapper
runner.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/gen.py", line 508, in run
yielded = self.gen.throw(*exc_info)
File "/Library/Python/2.7/site-packages/tornado_mysql/connections.py", line 790, in connect
yield stream.connect(addr)
tornado.gen.BadYieldError: yielded unknown object None
Using the debugger I can see the stream.connect calls into the Tornado iostream.py and goes into
try:
self.socket.connect(address)
except socket.error as e:
# In non-blocking mode we expect connect() to raise an
# exception with EINPROGRESS or EWOULDBLOCK.
#
# On freebsd, other errors such as ECONNREFUSED may be
# returned immediately when attempting to connect to
# localhost, so handle them the same way as an error
# reported later in _handle_connect.
if e.args[0] not in (errno.EINPROGRESS, errno.EWOULDBLOCK):
gen_log.warning("Connect error on fd %d: %s",
self.socket.fileno(), e)
self.close(exc_info=True)
return
self._connect_callback = stack_context.wrap(callback)
self._add_io_state(self.io_loop.WRITE)
and the exception argument is EINPROGRESS as expected.
I did notice that the argument callback is None. Therefore the yield would correctly 'yield' None. (If my understanding is correct?)
http://www.tornadoweb.org/en/stable/iostream.html#tornado.iostream.IOStream.connect
Changed in version 4.0: If no callback is given, returns a Future.
Maybe your tornado is too old.
Anyway, I don't use my time for this project anymore.