Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed.freenet.ag!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: Cannot get the value from dogpile.cache from different modules. Date: Tue, 29 Dec 2015 20:11:17 +0100 Organization: None Lines: 49 Message-ID: References: <7c8df879-b03a-4323-90c5-3221dd1eced2@googlegroups.com> <10871dc8-ee11-41d8-ad3c-c0aab267be64@googlegroups.com> <8c87a009-57f7-45c6-bbf8-5c51411758e1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de L/w5KNS70euZLZf4aWmxaQsbBftx6Iu0+dB1qwP4obIw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assignment': 0.07; 'namespace': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'statements': 0.09; 'example:': 0.10; 'python': 0.10; 'def': 0.13; '"global"': 0.16; '(directly': 0.16; 'indirectly)': 0.16; 'mailinglist': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'variable.': 0.16; 'wrote:': 0.16; 'example.': 0.18; 'tells': 0.18; 'variable': 0.18; '>>>': 0.20; 'simpler': 0.22; 'code,': 0.23; 'sets': 0.23; 'import': 0.24; 'feature': 0.24; 'module': 0.25; 'header:User-Agent:1': 0.26; 'example': 0.26; 'header:X-Complaints-To:1': 0.26; 'subject:skip:d 10': 0.27; 'function': 0.28; 'cat': 0.29; 'unlikely': 0.29; 'print': 0.30; 'code': 0.30; 'another': 0.32; 'related': 0.32; 'statement': 0.32; 'source': 0.33; 'running': 0.34; 'add': 0.34; 'so,': 0.35; 'something': 0.35; 'problem.': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'thought': 0.37; 'no,': 0.38; 'subject:from': 0.39; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'your': 0.60; 'subject:get': 0.81; 'complexity': 0.84; 'subject:value': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd90e9.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100968 xeon Mailinglist wrote: > No, I cannot get a simpler example. The simpler example works, and in my > code, it doesn't. Then you have to add/remove complexity until you find the problematic statements. > I thought that it was something related to the variable > `region`, but I declare it as global. The "global" statement tells a function that a name in the module namespace should be used even though there is an assignment to that name inside the function. Example: _value = 0 def next_int(): global _value _value += 1 return _value It is unlikely that this feature will affect your problem. > So, I think that all the sets will > go to the same variable. You can add print statements to your getters/setters >>> from dogpile.cache import make_region >>> region = make_region() >>> region.configure("dogpile.cache.memory") >>> region.backend to see if the object IDs are the same (I bet they aren't). Another shot in the dark: an unobvious source of running code twice is when you import (directly or indirectly) the main script: $ cat demo.py import demo print "demo" $ python demo.py demo demo