@Transactional(propagation = Propagation.REQUIRED)在线程中不起作用

时间:2018-12-22 04:37:15

标签: multithreading spring-mvc annotations transactional

我已经创建了手动交易,但是可以正常工作,但是使用交易注释时,由于出现以下错误而失败

错误:

  • 无法初始化代理-没有会话
  • org.hibernate.LazyInitializationException:无法初始化代理-没有会话

错误

  

com.krawler.common.service.ServiceException:系统故障:getJournalEntryJson:无法初始化代理-没有会话   原因:org.hibernate.LazyInitializationException:无法初始化代理-没有会话

代码结构

sync def index(request):
    async with aiohttp.ClientSession() as client:
        data=await(email_sending(client))
        await client.post('http://127.0.0.1:8000/acc/signup/',data=data)
        return web.Response(text="OK")

async def email_sending(client):
    async with client.get('http://www.mocky.io/v2/5c1ba9c633000052007fd919') as resp:
        resp=await(resp.json())
        totp = pyotp.TOTP('base32secret3232')
        otp=totp.now()
        smtp.sendmail("you@gmail.com",resp['email'], otp)
        sucess=await(email_verification(otp,client))


async def email_verification(otp,client):
    # async with client.Session() as client:
    async with client.get('http://127.0.0.1:8000/connect/hello/') as v_otp:
        v_otp=await(v_otp.json())
        print(v_otp)

0 个答案:

没有答案