[ZODB-Dev] Multiple threads connecting to ZODB
Dieter Maurer
dieter at handshake.de
Fri Nov 25 15:57:49 EST 2005
Alex Couper wrote at 2005-11-25 16:30 +0000:
>I am having trouble creating connections from different threads to my zodb.
>In the main thread, I create/get the database using this:
>
>storage=FileStorage('my.fs')
>db=DB(storage)
>
>The main thread subsequently creates other threads, and I would like those
>threads to be able to have access to the 'db' instance created in the main
>thread. In that way I would be able to write:
>
>connection = db.open() in those threads.
>
>This is all very manageable in most of the threads that I run, as I can pass
>the db instance in as an argument, however there is one thread that I have
>to (for one reason or another) run using os.system and then the file name.
>This means that it can have no idea about the db created in the main thread.
This means that you need ZEO. Only a single process is allowed
to open a FileStorage read/write. If several processes
need to access such a FileStorage (as in your example), they
must do it indirectly via ZEO.
With ZEO, the "os.system"ed process would open a new "DB" to the same
("ZEOClient") storage.
--
Dieter
More information about the ZODB-Dev
mailing list