I am running several processes using multiprocessing.Pool
Each process must query my mysql database.
I currently connect to the database once and then exchange the connection between processes
This works, but sometimes I get weird errors. I have confirmed that errors occur when querying the database.
I realized that the problem is that the same connection is used for all processes.
When I searched for the answer, I came across this q & a
How to split a single MySQL database connection between multiple processes in Python
So, I was looking for the class pooling.MySQLConnectionPool
If I understand that. I will create a pool with several connections and share the pool between processes. Then each process looks at this pool, and if the connection is available, use it or wait until the connection is released.
But then I found this q & a
Access to the MySQL connection pool from Python multiprocessing
At first it seems that the “mate” confirms what I suspected, but at the same time it rejects the use of the pool setting for process sharing
( ) ( , ),
, , .
?
, mata , , init
p = Pool(initializer=init)
Pool.map() Pool.map_async() map_async (q, ConnObj) ?
,
- , db
. , : qaru.site/questions/1575933/...
, , , . . .
Python, fifos .. .
mysql ?
...