When trying to load a given scenario in more than one thread, we see the following issue:
import ixmp
p = ixmp.Platform()
p.Scenario('MESSAGEix-GLOBIOM_BvR_OFR1', 'NPi2020_Net0')
In [1]: import multiprocessing, subprocess
In [2]: n=2; pool=multiprocessing.Pool(n); pool.map(subprocess.call, [('python', 'foo.py')] * n)
INFO:root:launching ixmp.Platform using config file at '/home/gidden/work/iiasa/message/properties_files/enedb.properties'
INFO:root:launching ixmp.Platform using config file at '/home/gidden/work/iiasa/message/properties_files/enedb.properties'
Nov 21, 2018 9:39:29 AM org.flywaydb.core.internal.util.VersionPrinter printVersion
INFO: Flyway 4.2.0 by Boxfuse
Nov 21, 2018 9:39:29 AM org.flywaydb.core.internal.util.VersionPrinter printVersion
INFO: Flyway 4.2.0 by Boxfuse
Nov 21, 2018 9:39:30 AM org.flywaydb.core.internal.dbsupport.DbSupportFactory createDbSupport
INFO: Database: jdbc:oracle:thin:@gp3.iiasa.ac.at:1521:GP3 (Oracle 12.1)
Nov 21, 2018 9:39:30 AM org.flywaydb.core.internal.dbsupport.DbSupportFactory createDbSupport
INFO: Database: jdbc:oracle:thin:@gp3.iiasa.ac.at:1521:GP3 (Oracle 12.1)
Nov 21, 2018 9:39:30 AM org.flywaydb.core.internal.command.DbValidate validate
INFO: Successfully validated 11 migrations (execution time 00:00.030s)
Nov 21, 2018 9:39:30 AM org.flywaydb.core.internal.command.DbValidate validate
INFO: Successfully validated 11 migrations (execution time 00:00.031s)
2018-11-21 09:39:31,049 INFO at.ac.iiasa.ixmp.Platform:111 - Welcome to the IX modeling platform!
2018-11-21 09:39:31,050 INFO at.ac.iiasa.ixmp.Platform:112 - connected to database 'ixENE-DB@GP3'...
/home/gidden/.local/lib/python3.5/site-packages/ixmp/core.py:171: UserWarning: The constructor `mp.Scenario()` is deprecated, please use `ixmp.Scenario(mp, ...)`
warnings.warn('The constructor `mp.Scenario()` is deprecated, '
2018-11-21 09:39:31,112 INFO at.ac.iiasa.ixmp.objects.Scenario:218 - loading Scenario 'MESSAGEix-GLOBIOM_BvR_OFR1|NPi2020_Net0' by version id (version: 1, runid: 18489)...
2018-11-21 09:39:31,113 INFO at.ac.iiasa.ixmp.Platform:111 - Welcome to the IX modeling platform!
2018-11-21 09:39:31,115 INFO at.ac.iiasa.ixmp.Platform:112 - connected to database 'ixENE-DB@GP3'...
/home/gidden/.local/lib/python3.5/site-packages/ixmp/core.py:171: UserWarning: The constructor `mp.Scenario()` is deprecated, please use `ixmp.Scenario(mp, ...)`
warnings.warn('The constructor `mp.Scenario()` is deprecated, '
2018-11-21 09:39:31,179 INFO at.ac.iiasa.ixmp.objects.Scenario:218 - loading Scenario 'MESSAGEix-GLOBIOM_BvR_OFR1|NPi2020_Net0' by version id (version: 1, runid: 18489)...
2018-11-21 09:39:31,541 INFO at.ac.iiasa.ixmp.objects.Scenario:241 - done loading Scenario from the database!
2018-11-21 09:39:31,571 INFO at.ac.iiasa.ixmp.objects.MsgScenario:457 - spatial and temporal disaggregation maps assignment
2018-11-21 09:39:31,590 INFO at.ac.iiasa.ixmp.objects.MsgScenario:573 - period mapping assignment
2018-11-21 09:39:31,612 INFO at.ac.iiasa.ixmp.objects.Scenario:241 - done loading Scenario from the database!
2018-11-21 09:39:31,613 INFO at.ac.iiasa.ixmp.objects.MsgScenario:599 - duration period assignment
2018-11-21 09:39:31,636 INFO at.ac.iiasa.ixmp.objects.Scenario:1826 - committing changes of Scenario 'MESSAGEix-GLOBIOM_BvR_OFR1|NPi2020_Net0' to the database (runid: 18489)...
Traceback (most recent call last):
File "foo.py", line 4, in <module>
p.Scenario('MESSAGEix-GLOBIOM_BvR_OFR1', 'NPi2020_Net0')
File "/home/gidden/.local/lib/python3.5/site-packages/ixmp/core.py", line 174, in Scenario
return Scenario(self, model, scen, version, scheme, annotation, cache)
File "/home/gidden/.local/lib/python3.5/site-packages/ixmp/core.py", line 460, in __init__
self._jobj = mp._jobj.getScenario(model, scenario)
jpype._jexception.IxExceptionPyRaisable: at.ac.iiasa.ixmp.exceptions.IxException: This Scenario is currently locked by user gidden
2018-11-21 09:39:32,907 INFO at.ac.iiasa.ixmp.objects.Scenario:601 - done updating Scenario 'MESSAGEix-GLOBIOM_BvR_OFR1|NPi2020_Net0' to the database (runid: 18489, version: 1)!
2018-11-21 09:39:32,912 INFO at.ac.iiasa.ixmp.objects.MsgScenario:457 - spatial and temporal disaggregation maps assignment
2018-11-21 09:39:32,912 INFO at.ac.iiasa.ixmp.objects.MsgScenario:573 - period mapping assignment
2018-11-21 09:39:32,913 INFO at.ac.iiasa.ixmp.objects.MsgScenario:599 - duration period assignment
/home/gidden/.local/lib/python3.5/site-packages/ixmp/core.py:468: UserWarning: Using `ixmp.Scenario` for MESSAGE-scheme scenarios is deprecated, please use `message_ix.Scenario`
warnings.warn('Using `ixmp.Scenario` for MESSAGE-scheme scenarios '
Out[2]: [0, 1]