Closed vladiibine closed 7 years ago
momoko version ==2.2.4
.
I tried with Momoko==1.1.6
but then I only get a None
object after calling db.execute.
When you hit CTRL-C in a freezed app, what do you see in Traceback?
One more question: how do you run this script exactly? (there is no main...)
I forgot to specify that I'm using py.test to test this, but you probably could tell that.
Anyway, this is the traceback if I run the module with unittest, - the same error still happens:
(venv) 14:37]user ~/work/my-app $ python my_script.py
Reaches here - calling pool.connect() - mm85
Just before making the http request - mau5
Before running pool.execute() - btyg8
db.execute returned this: <tornado.concurrent.Future object at 0x7f6b159ed7d0>
^CTraceback (most recent call last):
File "my_script.py", line 88, in <module>
unittest.main()
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/usr/lib/python2.7/unittest/main.py", line 232, in runTests
self.result = testRunner.run(self.test)
File "/usr/lib/python2.7/unittest/runner.py", line 151, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
test(result)
File "/usr/lib/python2.7/unittest/case.py", line 395, in __call__
return self.run(*args, **kwds)
File "/path/to/site-packages/tornado/testing.py", line 281, in run
self.__rethrow()
File "/path/to/site-packages/tornado/testing.py", line 272, in __rethrow
raise_exc_info(failure)
File "/path/to/site-packages/tornado/testing.py", line 276, in run
super(AsyncTestCase, self).run(result)
File "/usr/lib/python2.7/unittest/case.py", line 331, in run
testMethod()
File "/path/to/site-packages/tornado/testing.py", line 136, in __call__
result = self.orig_method(*args, **kwargs)
File "my_script.py", line 43, in test_200_on_good_data
response = self.fetch('/', body='request_body', method='POST', request_timeout=99999)
File "/path/to/site-packages/tornado/testing.py", line 406, in fetch
return self.wait()
File "/path/to/site-packages/tornado/testing.py", line 327, in wait
self.io_loop.start()
File "/path/to/site-packages/tornado/ioloop.py", line 862, in start
event_pairs = self._impl.poll(poll_timeout)
KeyboardInterrupt
More info: 2 IOLoop instances are being created in this test. One is created in the app, and another is created by the AsyncHTTPTestCase...I don't know why or whether it helps.
Yes, that's exactly the problem. When you bootstrap your app, you create an ioloop instance and pass it to db pool. The pool uses this instance. However when you run async test case, it creates its own instance of ioloop and starts it. I.e. db pool add callbacks to its own version of ioloop, that is not running, that's why nothing happens.
I suggest you create db pool during async test setUp method and pass it your app, to make sure that same io loop is used everywhere.
That was it. Thanks a lot for the help :)
Keep enjoying Momoko :)
We're including momoko in my company's code, because we saw it's cool.
However this first interaction with it didn't go so smoothly.
Could you please figure out what's wrong with our code?
I've boiled down our app's code to this:
The output after running this script is this:
The
pool.execute('select 1')
freezes forever.While debugging I got to somewhere in the code where there is a future with a connection set as the result. However this never passes.
What I did at first, was to not include those lines
...but that only gets me an error which says I'm a necromancer or something: "AssertionError: BUG: don't call reanimate when there is no one to reanimate" :grinning:
...So could you please guide me a little? I've lost 2 days of work because of this already.
Thanks a lot!