带有MySQL db的Turbogears2不能在多线程中更新表

2024-05-15 00:42:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我在MySQL数据库中使用turbogears2。使用相同的代码,单线程case可以更新/写入表。但是线程没有错误,但是没有写入成功。你知道吗

在turbogears2之外,多线程可以毫无问题地写入表。你知道吗

使用tg2的多线程没有错误或投诉。只是没有成功写入表。你知道吗

如果任何使用tg2的人能提供建议,我将非常感激。你知道吗


Tags: 代码数据库错误mysqlturbogears2tg2线程建议
1条回答
网友
1楼 · 发布于 2024-05-15 00:42:24

使用默认配置设置,在常规请求/响应周期中,TuborGears2使事务管理器能够在控制器处理完请求后自动向数据库提交更改。你知道吗

这在Wiki in 20 Minutes tutorial中介绍:

[...] you would usually need to flush the SQLAlchemy Unit of Work and commit the currently running transaction, those are operations that TurboGears2 transaction management will automatically do for us.

You don’t have to do anything to use this transaction management system, it should just work.

但是,对于在常规请求/响应周期之外的所有内容,例如stream,或者像scheduler这样的不同线程,都需要手动刷新会话并提交事务。这是用DBSession.flush()transaction.commit()执行的。你知道吗

相关问题 更多 >

    热门问题