Ok, Sorry.

I asked in the zodb as well, I found some people asking  about zodb here so 
I did it. Sorry again

El miércoles, 23 de abril de 2014 22:11:57 UTC, Ariel Argañaraz escribió:
>
> 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!
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to