Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails in multiprocessing even with 'r' mode #86

Open
Jwink3101 opened this issue Oct 30, 2018 · 3 comments
Open

Fails in multiprocessing even with 'r' mode #86

Jwink3101 opened this issue Oct 30, 2018 · 3 comments
Labels
bug medium difficult need info Need more information for reproduce

Comments

@Jwink3101
Copy link

As one would expect with a normal dictionary, it cannot be used (easily) with multiprocessing for writing values. However, a normal diction can be used for reading.

sqlitedict fails even with flag='r' in multiprocessing. This is almost certainly due to the threaded connection, but that connection is not needed for flag='r' since you can concurrently read an sqlite file.

Is not too hard to fix, but would add a major change in code flow

@menshikh-iv
Copy link
Contributor

@Jwink3101 thanks for the report, can you add a code example that reproduces your issue + maybe some tip about fixing if you have it.

@menshikh-iv menshikh-iv added bug medium difficult need info Need more information for reproduce labels Jan 17, 2019
@Jwink3101
Copy link
Author

Jwink3101 commented Jan 17, 2019 via email

@piskvorky
Copy link
Owner

piskvorky commented Jan 17, 2019

Yes, multiprocessing affects threads. AFAIK only the main thread remains running in a forked process.

Not sure this is a bug; it definitely has nothing to do with r mode. If we want to support transparent forking of SqliteDict objects, we'd need to think carefully about how to handle/restart running threads (not trivial).

OTOH, SqliteDict seeks to prevent multithreading issues with plain Sqlite (ProgrammingError: SQLite objects created in a thread can only be used in that same thread.). If you're using multiple processes instead of threads, either instantiate a separate SqliteDict in each, or just use plain sqlite?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug medium difficult need info Need more information for reproduce
Projects
None yet
Development

No branches or pull requests

3 participants