GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pubsub client relies on psutil which fails on appengine standard · Issue #3892 · googleapis/google-cloud-python

pubsub client relies on psutil which fails on appengine standard #3892

New issue
Copy link
New issue
Copy link
Closed
Closed
pubsub client relies on psutil which fails on appengine standard#3892
Copy link
Assignees
theacodes
Labels
api: pubsubIssues related to the Pub/Sub API.

Description

@ericbuehl
ericbuehl
opened on Aug 28, 2017
Issue body actions

Using:

Version: 0.28.2
Summary: Python Client for Google Cloud Pub/Sub
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: [email protected]
License: Apache 2.0
Location: /<proj>/.env/lib/python2.7/site-packages
Requires: googleapis-common-protos, grpc-google-iam-v1, grpcio, google-gax, psutil, google-cloud-core

I get the following stack trace when deployed to an app engine standard module:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/main.py", line 10, in <module>
    from google.cloud import pubsub
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/lib/google/cloud/pubsub.py", line 17, in <module>
    from google.cloud.pubsub_v1 import PublisherClient
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/lib/google/cloud/pubsub_v1/__init__.py", line 17, in <module>
    from google.cloud.pubsub_v1 import types
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/lib/google/cloud/pubsub_v1/types.py", line 20, in <module>
    import psutil
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/lib/psutil/__init__.py", line 80, in <module>
    from . import _pslinux as _psplatform
  File "/base/data/home/apps/s~<proj>/admin:20170828t162057.403716850892108987/lib/psutil/_pslinux.py", line 26, in <module>
    from . import _psutil_linux as cext
ImportError: cannot import name _psutil_linux

Activity

  1. theacodes commented on Aug 28, 2017

    @theacodes
    theacodes
    on Aug 28, 2017
    Contributor
    More actions

    The short answer is that due to limitations in the App Engine standard environment, this library is not supported there.

    The long answer(s) are over at #1893. I'm going to go ahead and close this as a duplicate, but by all means please continue to comment- the feedback is useful in communicating issues with the App Engine team. :)

  2. theacodes
    closed this as completedon Aug 28, 2017
  3. ericbuehl commented on Aug 28, 2017

    @ericbuehl
    ericbuehl
    on Aug 28, 2017
    Author
    More actions

    For what it is worth, old versions did not have this problem (eg pubsub-v1==0.15.4)

  4. theacodes commented on Aug 28, 2017

    @theacodes
    theacodes
    on Aug 28, 2017
    Contributor
    More actions

    Yep, that's true for a few libraries here. Mostly that was just accidental and there's a lot of edge cases where those would fail. We simply can not offer the same level of support in standard as we do elsewhere at this point in time, but we're working really hard to do so.

    In the meantime I'd recommend using the API client as mentioned in #1893 or pinning to an older version.

  5. dhermes
    added
    api: pubsubIssues related to the Pub/Sub API.
    invalid
    on Sep 27, 2017
  6. Chez commented on Oct 19, 2017

    @Chez
    Chez
    on Oct 19, 2017
    More actions

    I have recently run into an import error with psutils in the types.py called from google.cloud.pubsub_v1 on a GAE standard project inside Pycharm. I messed around for a day trying to find away around it, but no go. psutil imports in python run from the terminal and the console and from a vanilla python project but not from a GAE project. To double up on this I made a basic test of the two as seen below:

    Standard Vanilla Python Project:

    main.py contains

    import psutil
    
    def x():
        print "hello world"
    
    if __name__ == "__main__":
        x()
    

    Google App Engine Project -
    main.py contains

    import webapp2
    import psutil
    
    class MainHandler(webapp2.RequestHandler):
        def get(self):
            self.response.write('Hello world!')
    
    app = webapp2.WSGIApplication([
        ('/', MainHandler)
    ], debug=True)
    

    The import in the vanilla python project works fine, but the import in the GAE app returns the traceback:

    Traceback (most recent call last):
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
        handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
        handler, path, err = LoadObject(self._handler)
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
        obj = __import__(path[0])
      File "/Users/chez 1/google-app-engine-projects/untitled/main.py", line 18, in <module>
        import psutil
    ImportError: No module named psutil
    
  7. tseaver commented on Oct 19, 2017

    @tseaver
    tseaver
    on Oct 19, 2017
    Contributor
    More actions

    pubsub uses psutil only for computing a maximum amount of RAM to be used: ISTM we could fall back to some GAE-standard-appropriate default if import psutil raises.

  8. Chez commented on Oct 20, 2017

    @Chez
    Chez
    on Oct 20, 2017
    More actions

    It does raise on a mac El Capitan / Pycharm in GAE Standard env, even when installed as a third party to a libs directory. So now we have to write a cloud function to access the pubsub, not ideal...

    Traceback (most recent call last):

      File "/usr/local/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
        handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
      File "/usr/local/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
        handler, path, err = LoadObject(self._handler)
      File "/usr/local/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
        obj = __import__(path[0])
      File "/Users/chez 1/google-app-engine-projects/pitpit-gae/main.py", line 56, in <module>
        import supplier.api.v1.routes as supplierroutes
      File "/Users/chez 1/google-app-engine-projects/pitpit-gae/supplier/api/v1/routes.py", line 8, in <module>
        from supplier.api.v1.handlers import *
      File "/Users/chez 1/google-app-engine-projects/pitpit-gae/supplier/api/v1/handlers.py", line 9, in <module>
        import psutil
      File "/Users/chez 1/google-app-engine-projects/pitpit-gae/external/psutil/__init__.py", line 149, in <module>
        from . import _psosx as _psplatform
      File "/Users/chez 1/google-app-engine-projects/pitpit-gae/external/psutil/_psosx.py", line 16, in <module>
        from . import _psutil_osx as cext
      File "/usr/local/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 965, in load_module
        raise ImportError('No module named %s' % fullname)
    
    Reacted by David Bernat and Thomas Sileo
  9. davidbernat commented on Dec 25, 2017

    @davidbernat
    davidbernat
    on Dec 25, 2017
    More actions

    What was the solution to this? I am having the same issue with _psutil_osx.

  10. dhermes commented on Jan 3, 2018

    @dhermes
    dhermes
    on Jan 3, 2018
    Contributor
    More actions

    @davidbernat I would recommend putting a custom psutil in your lib/ that just returns a mocked result.

  11. davidbernat commented on Jan 15, 2018

    @davidbernat
    davidbernat
    on Jan 15, 2018
    More actions

    @dhermes Thank you for your suggestion. Can you point me to a reference which will walk me through which methods to mock in psutil? Being unfamiliar with the library I do not know to what extent is safe to mock without eliminating other useful or essential features of the library. Thank you again.

  12. dhermes commented on Jan 15, 2018

    @dhermes
    dhermes
    on Jan 15, 2018
    Contributor
    More actions

    I would just grep for usage of psutil in your application. It's a third-party app (i.e. from PyPI) so you only need to check your application code.

  13. Alexander-Minyushkin
    added 2 commits that reference this issue on Apr 23, 2018

    dependency on psutil removed

    00a38d4

    Removed dependency on psutil

    34fa34a
  14. JustinBeckwith
    assigned
    theacodes
    on Feb 1, 2021
  15. parthea
    added a commit that references this issue on Sep 22, 2023

    chore: move samples from python-docs-sample (#33)

    This issue will close once commit 69c4425 is merged into the 'main' branch.
    69c4425
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @theacodes
    theacodes

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.