fix: articles.py get_article 链式 await coroutine 报错(.first())
This commit is contained in:
16
scripts/_tscript.py
Normal file
16
scripts/_tscript.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import asyncio
|
||||
from app.services.translation.service import service
|
||||
from app.redis_client import get_redis
|
||||
async def main():
|
||||
r = get_redis(); await r.ping()
|
||||
print('before:', await r.get('translation:month:202606') or 0, flush=True)
|
||||
res1 = await service.translate('Breaking news from Reuters today.', source='en', target='zh')
|
||||
print(' call 1: engine=', res1.engine, 'chars=', res1.chars, 'text=', res1.text[:40], flush=True)
|
||||
print('after 1:', await r.get('translation:month:202606') or 0, flush=True)
|
||||
res2 = await service.translate('The market fell sharply after the announcement.', source='en', target='zh')
|
||||
print(' call 2: engine=', res2.engine, 'chars=', res2.chars, flush=True)
|
||||
print('after 2:', await r.get('translation:month:202606') or 0, flush=True)
|
||||
res3 = await service.translate('Breaking news from Reuters today.', source='en', target='zh')
|
||||
print(' call 3 (cache): cached=', res3.cached, 'engine=', res3.engine, flush=True)
|
||||
print('after 3:', await r.get('translation:month:202606') or 0, flush=True)
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user