Skip to content

Commit 776ac32

Browse files
committed
Don't create PubSub topic with create_topic()
1 parent 1d98ed7 commit 776ac32

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "thunagen"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
description = "Google Cloud function to generate thumbnail for images in Google Storage."
55
authors = ["Nguyễn Hồng Quân <ng.hong.quan@gmail.com>"]
66
maintainers = [

thunagen/functions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import json
22
import time
3-
import urllib.parse
43
from io import BytesIO
54
from pathlib import PurePosixPath
65
from typing import Dict
76
from collections import deque
7+
from urllib.parse import quote_plus
88

99
import lazy_object_proxy
1010
from logbook import Logger
@@ -79,12 +79,11 @@ def delete_thumbnails(bucket: storage.Bucket, orpath: PurePosixPath):
7979

8080
def notify_thumbnails_generated(project_id: str, original_path: str, generated: Dict[str, str]):
8181
publisher = pubsub_v1.PublisherClient()
82-
topic_path = publisher.topic_path(project_id, urllib.parse.quote_plus(f'{TOPIC_PREFIX}/{original_path}'))
82+
topic_path = publisher.topic_path(project_id, quote_plus(f'{TOPIC_PREFIX}/{original_path}'))
8383
logger.debug('Publish to: {}', topic_path)
84-
topic = publisher.create_topic(topic_path)
8584
data = json.dumps(generated).encode()
8685
futures = deque()
87-
futures.append(publisher.publish(topic, data))
86+
futures.append(publisher.publish(topic_path, data))
8887
# Google Cloud's Future object cannot be checked with Python concurent.futures module
8988
for i in range(4):
9089
if all(f.done() for f in futures):

0 commit comments

Comments
 (0)