Reputation: 4323
I need to publish Pub/Sub event in my infrastructure. So, I wrote the background Google Cloud Function that subscribed on topic scan-dead-locks. It will read database and release all crashed not closed locks on documents. This function should be executed periodically every 20 minuets, for example. As I investigated, there is no way to trigger Pub/Sub event directly by App Engine's Cron service. I wrote a python script that should do that (used App Engine's examples), but, the final issue left is that libraries at runtime where not found. So, I've got this error.
And this files.
app.yaml
runtime: python27
threadsafe: no
handlers:
- url: /trigger-scan-dead-locks
script: trigger-scan-dead-locks.py
login: admin
appengine_config.py
from google.appengine.ext import vendor
vendor.add('lib')
cron.yaml
cron:
- description: scan for dead locks and release locks
url: /trigger-scan-dead-locks
schedule: every 20 mins
trigger-scan-dead-locks.py
from apiclient import discovery
pubsub = discovery.build('pubsub', 'v1')
pubsub.projects().topics().publish(topic="scan-dead-locks").execute()
Example was taken from here https://github.com/GoogleCloudPlatform/reliable-task-scheduling-compute-engine-sample.
Maybe the general question that might solve the issue, how the libraries managed here (I already read documentation, but it was not really helpful)? And also I found another examples with from google.cloud import pubsub
library declaration, but it didn't worked because of absent library as well.
Upvotes: 0
Views: 461
Reputation: 11370
Sounds like you don't have googleapiclient in your lib
directory.
Couple of things:
1) try from googleapiclient import discovery
<- newer version
2) $ cd
to your project directory, then $ pip install -t lib google-api-python-client
Upvotes: 1