Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70737

Problems with ZODB, I can not persist and object accessed from 2 threads

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <arielin82@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; '"""': 0.07; 'filename:fname piece:py': 0.07; 'modify': 0.07; 'none:': 0.07; 'skip:" 60': 0.07; 'executed': 0.09; 'def': 0.12; 'creates': 0.14; 'thread': 0.14; 'changes': 0.15; '%r"': 0.16; "'.lock')": 0.16; '33,': 0.16; 'subject:Problems': 0.16; 'subject:object': 0.16; 'subject:threads': 0.16; 'thread,': 0.16; 'threads.': 0.16; 'url:file': 0.16; 'do.': 0.18; 'trying': 0.19; 'commit': 0.19; 'skip:f 30': 0.19; 'seems': 0.21; 'example': 0.22; 'manual': 0.22; 'separate': 0.22; 'skip:\xa0 20': 0.24; 'skip:" 30': 0.26; 'second': 0.26; 'skip:" 20': 0.27; 'raise': 0.29; 'skip:& 60': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:& 70': 0.31; 'file': 0.32; 'class': 0.32; 'this.': 0.32; 'run': 0.32; 'open': 0.33; '(most': 0.33; 'skip:& 30': 0.33; 'skip:_ 10': 0.34; 'subject:from': 0.34; 'subject:with': 0.35; 'connection': 0.35; 'transaction': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'skip:" 50': 0.36; 'should': 0.36; 'error.': 0.37; 'sometimes': 0.38; 'skip:& 10': 0.38; '8bit%:4': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; "couldn't": 0.39; 'subject:can': 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'how': 0.40; 'tell': 0.60; 'new': 0.61; 'skip:* 10': 0.61; 'here:': 0.62; 'save': 0.62; 'different': 0.65; 'self.run()': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=hHqa6bBDbj2AMxsr2MK4YdOz3THIJbhg3gWVekmPkws=; b=DBqGkMZJOmoTslhiK9+vXCAZYGMdMLw7TwiE7PqSGH0Jy6T8mTO3TDc1rA61ZCTPsA 1HDtVcyKh4TwvkURtg06a6fqpETvkXJoMUfs3Twhz7T9EflaAOsQQYgz3kZC2J+8/0Gb HKIMCUaLmYGA+AQw77J3sHcbYmNrvUjsuCahHoUvaYJq08XAK4sWBy+7IT/gmG3kfj13 Z/UUZ2N0FvlzDKpHYM/WO99LolPtJatuYBVajcU0Wf1yiBvlPRXoi2uBWOSobA2zvhcS wmsvrbKeN1Qa+ftsFlYdkVH5Cr9yDIanO2NMm/UGI6a7grQqeKpuGwjbgel98x5b0bh5 Cg3w==
MIME-Version 1.0
X-Received by 10.152.22.136 with SMTP id d8mr85017laf.66.1398805527123; Tue, 29 Apr 2014 14:05:27 -0700 (PDT)
Date Tue, 29 Apr 2014 21:05:24 +0000
Subject Problems with ZODB, I can not persist and object accessed from 2 threads
From Ariel Argañaraz <arielin82@gmail.com>
To python-list@python.org
Content-Type multipart/mixed; boundary=089e0158b6e48deefc04f834cac1
X-Mailman-Approved-At Wed, 30 Apr 2014 00:54:52 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9588.1398812094.18130.python-list@python.org> (permalink)
Lines 194
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398812094 news.xs4all.nl 2837 [2001:888:2000:d::a6]:37826
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70737

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello, I am sorry I am stuck in this. And I need some help

I want to persist an Object with ZODB, the object can be accessed from 2
different threads. The ZODB manual says:

A multi-threaded program should open a separate Connection instance for
each thread. Different threads can then modify objects and commit their
modifications independently.

But there isn't an example of how to create a connection for each thread.
Can someone tell me how to connect to the same DB from 2 threads??

I attached an example of what I am trying to do.

And I get this error.

Traceback (most recent call last):
 File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
   self.run()
 File "/usr/lib/python2.7/threading.py", line 763, in run
   self.__target(*self.__args, **self.__kwargs)
 File "main.py", line 33, in thread_1
   storage = FileStorage("/tmp/asdasd.fs")
 File "/usr/lib/python2.7/site-packages/ZODB/FileStorage/FileStorage.py",
line 164, in *_init_*
   self._lock_file = LockFile(file_name + '.lock')
 File "/usr/lib/python2.7/site-packages/zc/lockfile/__init__.py", line 84,
in *_init_*
   _lock_file(fp)
 File "/usr/lib/python2.7/site-packages/zc/lockfile/__init__.py", line 59,
in _lock_file
   raise LockError("Couldn't lock %r" % file.name)
LockError: Couldn't lock '/tmp/asdasd.fs.lock'


IF I don't connect in the "thread_1" class I can change things but
sometimes the changes from the main thread are not commited.

When I debug, I can see that when a change is made from the Second thread,
the "transaction_manager" creates a new Transaction here:

#manager.py
    def get(self):
        """ See ITransactionManager.
        """
        if self._txn is None:
            self._txn = Transaction(self._synchs, self)
        return self._txn

When it happens that commit Seems to be executed succesfully but it doest
save the changes to the DB.

-- 
Ariel Argañaraz

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Problems with ZODB, I can not persist and object accessed from 2 threads Ariel Argañaraz <arielin82@gmail.com> - 2014-04-29 21:05 +0000

csiph-web