brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
8 stars 21 forks source link

Are concurrent database modifications supported in Brightway? #152

Closed shantanu1singh closed 8 months ago

shantanu1singh commented 10 months ago

Copying over my question on SO here too.

I'm trying to run Brightway (Version 2.5) on an application with the intent to support the creation of multiple new activities/exchanges in parallel on the same database (Ecoinvent). Does Brightway support concurrent execution of database modifications?

I tried doing this but I keep getting into errors such as 'database is locked' or 'LockError' (stack trace below).

Stack:

File "/Users/shantanu/repos/carbontrail-brightway/ef_module.py", line 490, in create_location_specific_activity new_activity = original_activity.copy() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/bw2data/project.py", line 446, in writable_project return wrapped(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/bw2data/backends/proxies.py", line 446, in copy activity.save() File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/bw2data/project.py", line 446, in writable_project return wrapped(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/bw2data/backends/proxies.py", line 287, in save IndexManager(Database(self["database"]).filename).update_dataset(self._data) File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/bw2data/search/indices.py", line 50, in update_dataset writer = self.get().writer() ^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/whoosh/index.py", line 464, in writer return SegmentWriter(self, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shantanu/anaconda3/lib/python3.11/site-packages/whoosh/writing.py", line 515, in init raise LockError whoosh.index.LockError

I'm using a single project across the app and have even tried setting bd.projects.read_only to False.

cmutel commented 8 months ago

Closing in favor of SO