0

I have a class named 'DbWorker' to access data in SQlite DB. I design parallel procedure to create 3 cores by python multiprocessing. Each processors has 'DbWorker' object to process data and access DB.

Now I encountered a problem explained as follows:

time1: core-1: update data and insert them in DB
time2: core-2: look-up DB, but no data in DB
time3: core-3: the same problem as core-2
time4: core-1: look-up DB and DB has updated data

I found an article How to share a single SQLite connection in multi-threaded Python application. Then I used 'Lock' to avoid data competition, but nothing's happened.

Is there any way to solve this problem??

Eric

2
  • Does DbWorker commit the transaction after writing to db? Commented Jun 26, 2019 at 12:30
  • yes, I run session.commit() after session.add(data) immediately. Commented Jun 27, 2019 at 2:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.