Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Legacy Python 2 migration from pull queues to PubSub -- grpcio version issues

I inherited a legacy Python 2.7 App Engine app that I'm migrating to the Python 3 environment.

The Google migration guide for "pull" tasks, recommends moving them to use PubSub. I've rewritten our code to use PubSub, and can successfully run it in a local server both against an emulator and against production PubSub topics.

However, I am not able to deploy this new code due to version incompatibilities with grpcio:
- I'm using Python library `google-cloud-pubsub` v 1.7.2, which the documentation lists as the last version compatible with Python 2.7
- `google-cloud-pubsub` v 1.7.2 needs `grpcio` v 1.12.0, which fixes this bug
- the legacy App Engine standard environment only allows installing `grpcio` via the "built-in" libraries specified in `app.yml`, which only provides `grpcio` v 1.0.0 (cf. https://cloud.google.com/appengine/docs/legacy/standard/python/tools/built-in-libraries-27)

I've come across a proposed workaround that simply catches the exception caused by the incompatibility, which might be bearable until we can get fully on Python 3, but is gross: https://github.com/googleapis/python-pubsub/issues/742#issuecomment-1224582470

Is there a combination of library versions that would allow me to use google-cloud-pubsub with Python 2.7 on the old App Engine environment?

What other alternatives do I have to do this migration? (Other than moving this code completely outside of App Engine for the moment, say to a Cloud Run function?)

0 1 137
1 REPLY 1


@anaulin wrote:

the legacy App Engine standard environment only allows installing `grpcio` via the "built-in" libraries specified in `app.yml`, which only provides `grpcio` v 1.0.0


Listing it in your app.yaml means you want Google to install it when you deploy your code.

Given that this is Python 2.7, you can install a package locally and then deploy it as part of your source code (which also means you remove it from the 'built-in' libraries section of your app.yaml file).

Essentially I'm saying,  try and install the version of grpcio that you need locally and then deploy it as part of your source code.

 

   ......NoCommandLine ......
https://nocommandline.com
Analytics & GUI for App Engine,
Cloud Run & Datastore Emulator