Regarding thread safety. Aaron has indicated he will look into this, but for the moment, mutexes would need to be used. Like most of us, Aaron has a full time job and little free time. Since Gadfly is open source, perhaps Aaron would accept volunteer efforts to tackle threads?
Unfortunately this is a very tricky issue with difficult to anticipate side-effects all through the engine. I don't recommend it especially since it would be sufficiently different from the current engine to constitute essentially a new implementation. I have been thinking about a new implementation that would support (limited) threading in the same engine. This is somewhere in the future. For now I don't see why you can't simply guard each gadfly database instance by a mutex and thus serialize access to the database. I would even recommend this for other database engines since otherwise it might be possible for two threads to deadlock/livelock waiting for the same data item locks in the data engine to clear. I've seen this problem even with CGI scripts at client sites. [This is another problem that tends to only show up when the system is heavily loaded under real use :)] -- Aaron Watters === Jim Ahlstrom's catch 22 correlary: "If you think you are smart enough to write multithreaded programs, you're not."