[storm] Threading question
Gerdus van Zyl
gerdusvanzyl at gmail.com
Tue Jan 15 14:32:13 GMT 2008
Ok silly me, it's wasn't a storm problem only the way storm uses
sqlite. There is a sqlite connection parameter check_same_thread that
by default is set to true that was giving me the exception when used
by different threads.
I had to change the storm source (sqlite.py) class SQLite, connect method from:
raw_connection = sqlite.connect(self._filename, timeout=self._timeout,
isolation_level=None)
to
raw_connection = sqlite.connect(self._filename, timeout=self._timeout,
isolation_level=None,check_same_thread=False)
If this small change can be included in some manner that would be great.
So now I can use one store object in my program. It works correctly
since it never uses the store and sqlite concurrently, just from
different threads.
~Gerdus
On Jan 11, 2008 5:27 PM, Gerdus van Zyl <gerdusvanzyl at gmail.com> wrote:
> How can I move an object between stores?
> I am getting:
> WrongStoreError: [<class 'model.Entry'> : 22 - Stationary - A - 10] is
> part of another store
>
> my code looks like this:
> db = getStore() #thread local store
>
> for b in self.biz:
> oldstore = Store.of(b)
> oldstore.remove(b)
> db.add(b)
> db.flush()
> db.commit()
>
> In my GUI application it retrieves a list of items on the main thread
> and calls the above code in another thread in reaction to a click
> event.
>
> Thanks,
> Gerdus
>
More information about the storm
mailing list