App hangs on test
#409
-
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
import asyncio
from main import create_app
from configs import app_conf
async def test_endpoints():
app = await create_app()
results = []
base_url = f'http://127.0.0.1:{app_conf.get("port")}'
@app.before_serving
async def startup():
print("Starting up the app...")
@app.after_serving
async def shutdown():
print("Shutting down the app...")
await app.startup()
for rule in app.url_map.iter_rules():
print(rule)
await app.shutdown()
if __name__ == "__main__":
asyncio.run(test_endpoints()) This will print out
But it won't shut down on its own, and it hangs on that last line. |
Beta Was this translation helpful? Give feedback.
Answered by
skwzrd
Feb 23, 2025
Replies: 1 comment
-
Databases were still connected... I found out which database it was by using something like import sys
import traceback
for thread in threading.enumerate():
if thread is not threading.main_thread():
print(f'{thread.name=}')
traceback.print_stack(sys._current_frames()[thread.ident]) I created this decorator for the test functions. def close_all_dbs(func):
@wraps(func)
def wrapper(*args, **kwargs):
func(*args, **kwargs)
asyncio.run(db.pool_manager.close_pools())
asyncio.run(db.pool_manager.close_pools())
return wrapper |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
skwzrd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Databases were still connected... I found out which database it was by using something like
I created this decorator for the test functions.