ZODB problem to change an attribute from 2 diferent threads
19 views
Skip to first unread message
Ariel Argañaraz
unread,
Apr 23, 2014, 6:11:57 PM4/23/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
Hi, I have a problem with threads.
The documentation says: A process with multiple threads will often have multiple connections to the same database, with different threads having different connections.
But I don't Know if I create different connections in the right way.
I have 2 threads.
In the main.py, the connection works well with this: #main.py
db = ZODB.config.databaseFromURL('configs/database.conf') connection = db.open() root = connection.root()
I
have a function that change something in the object I want to persist.
When I use this function locally all works perfect, The element is
updated and saved. def changePos(self, x): """a function to change the x position of an element""" self.element._x = x self._p_changed = True transaction.commit() print "change success"
The second thread is launched from the main.py. It is a xml-rpc server. That serves the mentioned method "changePos()" i create the connection in that thread like this. db2 = ZODB.config.databaseFromURL('configs/database.conf') connection2 = db2.open() root2 = connection2.root()
But
the problem is that, when I call "changePos(3)" with a xml-rpc client.
It seems to do the job because it changes the X value and print the
"change success" message but when I stop the main.py and inspect the X
value from the data.fs with the Eye program or with another python
script to show the X value I can see that the X value is not "3" as I
would expect. So the change was not commited!
Can someone give
some help with this? maybe i am doing something wrong, or if anyone has
an example of how to deal with threads, i 'd be very gratefull.
BTW: I try to use the ZEO and I made and example with 2 diferent process and it works but I can't do it with 2 threads!
Chris McDonough
unread,
Apr 23, 2014, 6:17:12 PM4/23/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
On 04/23/2014 06:11 PM, Ariel Argañaraz wrote:
> Hi, I have a problem with threads.