Firstly, the SA docs on Session.add() do not mention anything about the method's return value, so I would assume it is expected to return None.

Secondly, I think you meant to add new_movie to the session, not movies(**movie_details), whatever that is :)

Thirdly, the standard Pyramid session (the one configured with ZopeTransactionExtension) is tied to Pyramid's request-response cycle, which may produce unexpected behavior in your situation. You need to configure a separate session which you will need to commit manually in store_movie_details. This session needs to use scoped_session so the session object is thread-local and is not shared across threads.

from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker

session_factory = sessionmaker(bind=some_engine)
AsyncSession = scoped_session(session_factory)

def store_movie_details(movie_id):

    session = AsyncSession()
    movie_details = scrape_data(movie_id)
    new_movie = Movie(**movie_details) # Movie is my model.

    session.add(new_movie)
    session.commit()

And, of course, this approach is only suitable for very light-weight tasks, and if you don't mind occasionally losing a task (when the webserver restarts, for example). For anything more serious have a look at Celery etc. as Antoine Leclair suggests.

多线程操作数据库_wanglx2012的专栏-CSDN博客

https://blog.csdn.net/wanglx_/article/details/20051517

2014年2月27日 ... 多线程最好不要共用一个连接以下是来自MSDN的一段话http://msdn.microsoft.com/ zh-cn/library/ms131686.aspx“SQL Server 2005 在访问数据库 ...

Pyramid: Multi-threaded Database Operation - Stack Overflow

https://stackoverflow.com/questions/24705323/pyramid-multi-threaded-database-operation

Firstly, the SA docs on Session.add() do not mention anything about the method's return value, so I would assume it is expected to return None .

多线程编程学习笔记——异步操作数据库- DotNet菜园- 博客园

https://www.cnblogs.com/chillsrc/p/8458933.html

2018年2月22日 ... 运行程序,如果数据库已经存在,则删除重建。当打开连接以及单独使用 OpenAsync和ExecuteNonQueryAsync方法执行SQL命令时,我们使用 ...

数据库多线程操作的弊端及简单有效的解决方案- 简书

https://www.jianshu.com/p/1ee9f0393fbb

2016年12月14日 ... 数据库操作是异步的,在高并发的情况下有可能出现以下的情形: 1、线程A对 数据库的表table_1进行插入操作,同时另一线程B同样对表table_2 ...

Realizing Parallelism in Database Operations: Insights from a ...

https://www.researchgate.net/profile/John_Cieslewicz/publication/220706908_Realizing_parallelism_in_database_operations_Insights_from_a_massively_multithreaded_architecture/links/0912f50b8369f2e456000000/Realizing-parallelism-in-database-operations-Insights-from-a-massively-multithreaded-architecture.pdf

Jun 25, 2006 ... The hardware trend toward multithreading for improved performance, including multicore and multithreaded chip designs [1, 11, 13, 17, 21, 23, 24] ...

多线程下不能操作数据库么? - SegmentFault 思否

https://segmentfault.com/q/1010000018936994

2019年4月20日 ... 我这边有个项目,是使用客户端socekt 连接服务获取数据并保存到数据库,但是 由于是一个客户端连接多个服务,目前只想到了多线程,但是在 ...

python多线程操作mysq - 云+社区- 腾讯云

https://cloud.tencent.com/developer/article/1571236

2021年1月27日 ... 使用多线程操作mysql数据库时,如果使用普通的连接,会出现数据重复的问题, 应该使用数据库连接池. 解决方法:使用数据库连接池,并且每次 ...

多线程并发访问数据库中不同记录时应该采用什么办法? - 知乎

https://www.zhihu.com/question/25390316

这个要么业务层加锁,要么使用版本号,加一个字段,或者使用数据库事物功能。 数据库本身的行级锁没用。行级锁只能保证更新该行的时候不会有其他线程操作 ...

multithreaded database operation in php - Stack Overflow

https://stackoverflow.com/questions/28474730/multithreaded-database-operation-in-php

You can use pcntl_fork inside your script to duplicate the thread and process 1000 entries per child thread.

Process Architecture

https://docs.oracle.com/database/121/CNCPT/process.htm

A database instance contains or interacts with multiple processes. ... In the multithreaded architecture, an Oracle process can be an operating system process or ...

多线程操作数据库问题。。郁闷啦。。 - OSCHINA

https://www.oschina.net/question/919301_88503

今天做多线程操作数据库,发现好多问题呢,现在整理如下: 1,com.microsoft. sqlserver.jdbc.SQLServerException: 没有需要传输的数据。

多线程操作数据库,保证事务的唯一性(真实有效) - gentlelions的 ...

https://my.oschina.net/gentlelions/blog/3111481

2019年9月26日 ... 网上搜罗了一大堆所谓的多线程操作数据库,保证事务同时提交回滚啊,有的文章 有点含量,有的就是纯属胡诌,浪费同学们的感情和时间,不过 ...

Android数据库多线程并发操作异常- 云+社区- 腾讯云

https://cloud.tencent.com/developer/article/1634981

2020年5月28日 ... 多线程. 单进程和多进程结果一样。 同时进行数据库的读操作不会产生任何问题;; 如果都需要创建表 ...

About single threaded versus multithreaded databases performance ...

https://dba.stackexchange.com/questions/2918/about-single-threaded-versus-multithreaded-databases-performance

May 24, 2011 ... Here is my opinion: Usually the bottleneck (or slowest part) of a DB system is the disk. The CPU only spikes during arithmetic operations, ...

Spring Transaction Management Over Multiple Threads - DZone Java

https://dzone.com/articles/spring-transaction-management-over-multiple-thread-1

Apr 25, 2017 ... Learn why Spring transactions over multiple threads fail, and how to use ... framework provides a comprehensive API for database transaction ...

IBM Knowledge Center

https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/rzahw/rzahwdbcco.htm

When you use databases in multithreaded programs, be aware of these ... Database operations that are threadsafe include: Create File, Add Member, Delete ...

One thread for all database operations or one thread for each db ...

https://softwareengineering.stackexchange.com/questions/361300/one-thread-for-all-database-operations-or-one-thread-for-each-db-operations

Nov 27, 2017 ... Database operations typically consist of multiple stages and allow for quite some parallel execution. Your single thread will block that.

Multithreaded Delphi Database Queries With dbGo (ADO)

https://www.thoughtco.com/multithreaded-delphi-database-queries-1058158

Feb 10, 2019 ... If you want to run this operation for more than one customer, you need to sequentially run the procedure for each of the selected customers. In a ...

Multithreading (computer architecture) - Wikipedia

https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)

In computer architecture, multithreading is the ability of a central processing unit ( CPU) to provide multiple threads of execution concurrently, supported by the operating system ... The purpose of interleaved multithreading is to remove all data dependency stalls from the execution pipeline. Since one thread is relatively  ...