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


Groups > comp.lang.python > #89725

Re: ImportError with pickle (Python 2.7.9), possibly platform dependent

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'algorithm': 0.04; 'subject:Python': 0.06; 'context': 0.07; 'differently': 0.07; 'namespace': 0.09; 'referenced': 0.09; 'testing,': 0.09; 'cc:addr :python-list': 0.11; 'different,': 0.16; 'dump': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hack,': 0.16; 'least.': 0.16; 'sys.modules': 0.16; 'wsgi': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; 'error': 0.23; 'script.': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; 'pickle': 0.31; 'lists': 0.32; 'stuff': 0.32; 'another': 0.32; 'quite': 0.32; 'linux': 0.33; 'running': 0.33; 'fri,': 0.33; "i'd": 0.34; 'could': 0.34; 'subject: (': 0.35; 'subject:with': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'application': 0.37; 'so,': 0.37; 'two': 0.37; 'list': 0.37; 'server': 0.38; 'ben': 0.38; 'question,': 0.38; 'pm,': 0.38; 'expect': 0.39; 'unable': 0.39; 'how': 0.40; 'full': 0.61; 'simply': 0.61; 'name': 0.63; 'answer.': 0.68; '2015': 0.84; 'fails,': 0.84; 'so...': 0.84; 'whereas': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=5nBMRGqhW/mhZPZfAwPKp8qS7N23vfelENbiejkyxAk=; b=znUJfUU/WqPi6gTp4NKQ9I9aHBAyVylRov6Id5FVDNeLFFeM2cFJQWMzp9baYfrJW9 ZXLAC63eatmjd32NtsoHh5BZKi+AUEQCBx+BcB4WcmjM2OJc5GLML6TeZBvK5oz75j3O nU9Kqmk1HXgmnkWdyvtQbDTOP+ms2Z9FYUcQpJS/yyKSqg9kysNG+PZ1YzqmuLI2ZvTm 4bYe0o3Mz4gkXP/ryw0JUiH4EIzZCBrD6Wi1BZdSIlTF0ulJGlbWcBCii7O5IZde6Uyd 0akkNQXycEO8YluNrKeQYTUWHihJ19GEJNKWYMMnlttLyOCuFehdBX5TgLo4Yr+6frVy 7L9A==
MIME-Version 1.0
X-Received by 10.107.160.202 with SMTP id j193mr11840824ioe.43.1430482168053; Fri, 01 May 2015 05:09:28 -0700 (PDT)
In-Reply-To <20a5c7bf-2163-4b7a-8495-30ce23239903@googlegroups.com>
References <494551ca-532f-4d4d-aff0-a3932416c8f4@googlegroups.com> <mailman.108.1430354695.3680.python-list@python.org> <20a5c7bf-2163-4b7a-8495-30ce23239903@googlegroups.com>
Date Fri, 1 May 2015 22:09:28 +1000
Subject Re: ImportError with pickle (Python 2.7.9), possibly platform dependent
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.9.1430482176.3347.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1430482176 news.xs4all.nl 2852 [2001:888:2000:d::a6]:53076
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:89725

Show key headers only | View raw


On Fri, May 1, 2015 at 9:01 PM, Ben Sizer <kylotan@gmail.com> wrote:
> Another good question, and this gives us the answer. The module lists are quite different, as I'd expect because the load happens in the context of the full application whereas the dump happens as a standalone script. But literally every module that is in the 'before dump' list is in the 'before load' list - except OMDBMap. Like the error says! What /is/ in the 'before load' list however is "my_wsgi_app.OMDBMap". The module has been imported, but the pickle algorithm is unable to reconcile the module in the WSGI app's namespace with the module referenced in the pickle file.
>
> So... I don't know how to fix this, but I do now know why it fails, and I have a satisfactory answer for why it is acting differently on the Linux server (and that is just because that is the only one running under WSGI). Two out of three isn't bad!
>

Cool! That's part way. So, can you simply stuff OMDBMap into
sys.modules prior to loading? It might be a bit of a hack, but it
should work for testing, at least. Conversely, you could change the
dump script to import via the name my_wsgi_app to make it consistent.

ChrisA

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


Thread

ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-04-29 09:01 -0700
  Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Chris Angelico <rosuav@gmail.com> - 2015-04-30 10:44 +1000
    Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-01 04:01 -0700
      Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Chris Angelico <rosuav@gmail.com> - 2015-05-01 22:09 +1000
        Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-13 03:23 -0700
      Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Peter Otten <__peter__@web.de> - 2015-05-01 14:34 +0200
        Re: ImportError with pickle (Python 2.7.9), possibly platform dependent Ben Sizer <kylotan@gmail.com> - 2015-05-13 03:27 -0700

csiph-web