Thread: [SQL-CVS] [ sqlobject-Bugs-3525829 ] KeyError in multiprocessing environment
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: SourceForge.net <no...@so...> - 2012-05-11 13:34:47
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Tracker Item Submitted) made by ljsilver You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) Assigned to: Nobody/Anonymous (nobody) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |
From: SourceForge.net <no...@so...> - 2012-05-11 13:35:41
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Comment added) made by ljsilver You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) Assigned to: Nobody/Anonymous (nobody) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- >Comment By: LJSilver (ljsilver) Date: 2012-05-11 06:35 Message: I've managed to fix it using the following monkey patch: def sqlobject_cache_put_monkey(self, id, cls, obj): try: self.caches[cls.__name__].put(id, obj) except KeyError: self.caches[cls.__name__] = sqlobject.cache.CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].put(id, obj) sqlobject.cache.CacheSet.put = sqlobject_cache_put_monkey ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |
From: SourceForge.net <no...@so...> - 2012-05-11 13:53:23
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) >Assigned to: Oleg Broytman (phd) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- >Comment By: Oleg Broytman (phd) Date: 2012-05-11 06:53 Message: What have you done to have the row without getting it first?! Did you get the row from DB in one process and passed it to the other process? How do you pass objects between processes? ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-11 06:35 Message: I've managed to fix it using the following monkey patch: def sqlobject_cache_put_monkey(self, id, cls, obj): try: self.caches[cls.__name__].put(id, obj) except KeyError: self.caches[cls.__name__] = sqlobject.cache.CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].put(id, obj) sqlobject.cache.CacheSet.put = sqlobject_cache_put_monkey ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |
From: SourceForge.net <no...@so...> - 2012-05-13 17:51:53
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Comment added) made by ljsilver You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) Assigned to: Oleg Broytman (phd) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-13 10:51 Message: Right. The row is fetched in one process and passed to the other using a queue. ---------------------------------------------------------------------- Comment By: Oleg Broytman (phd) Date: 2012-05-11 06:53 Message: What have you done to have the row without getting it first?! Did you get the row from DB in one process and passed it to the other process? How do you pass objects between processes? ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-11 06:35 Message: I've managed to fix it using the following monkey patch: def sqlobject_cache_put_monkey(self, id, cls, obj): try: self.caches[cls.__name__].put(id, obj) except KeyError: self.caches[cls.__name__] = sqlobject.cache.CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].put(id, obj) sqlobject.cache.CacheSet.put = sqlobject_cache_put_monkey ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |
From: SourceForge.net <no...@so...> - 2012-05-13 18:31:03
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository Status: Open Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) Assigned to: Oleg Broytman (phd) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- >Comment By: Oleg Broytman (phd) Date: 2012-05-13 11:31 Message: Aha, and the "queue" (whatever it is) passes objects between processes using pickle, I suspect. Hence there is a bug in SQLObject.__setstate__. Can you test the following patch? Index: main.py =================================================================== --- main.py (revision 4524) +++ main.py (working copy) @@ -1683,7 +1685,7 @@ self.__init__(_SO_fetch_no_create=1) self._SO_writeLock = threading.Lock() self.__dict__.update(d) - self.__class__._connection.cache.put(self.id, self.__class__, self) + self._connection.cache.created(self.id, self.__class__, self) def setterName(name): ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-13 10:51 Message: Right. The row is fetched in one process and passed to the other using a queue. ---------------------------------------------------------------------- Comment By: Oleg Broytman (phd) Date: 2012-05-11 06:53 Message: What have you done to have the row without getting it first?! Did you get the row from DB in one process and passed it to the other process? How do you pass objects between processes? ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-11 06:35 Message: I've managed to fix it using the following monkey patch: def sqlobject_cache_put_monkey(self, id, cls, obj): try: self.caches[cls.__name__].put(id, obj) except KeyError: self.caches[cls.__name__] = sqlobject.cache.CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].put(id, obj) sqlobject.cache.CacheSet.put = sqlobject_cache_put_monkey ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |
From: SourceForge.net <no...@so...> - 2012-05-25 16:34:03
|
Bugs item #3525829, was opened at 2012-05-11 06:34 Message generated for change (Comment added) made by phd You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: General Group: SQLObject from repository >Status: Closed Resolution: None Priority: 5 Private: No Submitted By: LJSilver (ljsilver) Assigned to: Oleg Broytman (phd) Summary: KeyError in multiprocessing environment Initial Comment: When disabling the cache, SQLObject works quiet well in a multiprocessing environment. Sometimes SQLObject throws KeyError from the sqlobject.cache.CacheSet.put method in the following line: self.caches[cls.__name__].put(id, obj) This seems to be because of a mapped object is put back to the DB without getting it from the DB in the same process. ---------------------------------------------------------------------- >Comment By: Oleg Broytman (phd) Date: 2012-05-25 09:34 Message: Ok, I applied my fix and committed it in revisions 4529-4531 (branches 1.2, 1.3 and the trunk). ---------------------------------------------------------------------- Comment By: Oleg Broytman (phd) Date: 2012-05-13 11:31 Message: Aha, and the "queue" (whatever it is) passes objects between processes using pickle, I suspect. Hence there is a bug in SQLObject.__setstate__. Can you test the following patch? Index: main.py =================================================================== --- main.py (revision 4524) +++ main.py (working copy) @@ -1683,7 +1685,7 @@ self.__init__(_SO_fetch_no_create=1) self._SO_writeLock = threading.Lock() self.__dict__.update(d) - self.__class__._connection.cache.put(self.id, self.__class__, self) + self._connection.cache.created(self.id, self.__class__, self) def setterName(name): ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-13 10:51 Message: Right. The row is fetched in one process and passed to the other using a queue. ---------------------------------------------------------------------- Comment By: Oleg Broytman (phd) Date: 2012-05-11 06:53 Message: What have you done to have the row without getting it first?! Did you get the row from DB in one process and passed it to the other process? How do you pass objects between processes? ---------------------------------------------------------------------- Comment By: LJSilver (ljsilver) Date: 2012-05-11 06:35 Message: I've managed to fix it using the following monkey patch: def sqlobject_cache_put_monkey(self, id, cls, obj): try: self.caches[cls.__name__].put(id, obj) except KeyError: self.caches[cls.__name__] = sqlobject.cache.CacheFactory(*self.args, **self.kw) self.caches[cls.__name__].put(id, obj) sqlobject.cache.CacheSet.put = sqlobject_cache_put_monkey ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=540672&aid=3525829&group_id=74338 |