googleapis / googleapis/google-cloud-python

Asyncio coroutines for common tasks

オープン
#15,653 コメント 14 件 リアクション 15 件 担当者 1 名 @abbrowne126 が担当を希望しています GitHub で見る
api: pubsub type: feature request
主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
3日 4時間
マージ済み PR(30日)
122

説明

The current status of asyncio has mostly been answered here already: https://github.com/googleapis/python-pubsub/issues/218#issuecomment-760778351

This feature request is to ask for a formal exposure of high-level awaitable methods for interacting with the PubSub library and reducing the use of threads. Although, if the library still wants to manage threads, that seems fine as long as how we use the library would be awaitable and the callback are run in the same event loop. I don't want to be too prescriptive on the implementation in my request.

Some examples, assuming `SubscriberClient` and `PublisherClient` were already setup...

example subscribe:

```python
async def my_func(msg):
# ... do something
pass

subscription_path = f"projects/{project_id}/subscriptions/{subscription}"
streaming_pull_async = subscriber.subscribe_async(subscription_path, callback=my_func,)

try:
await streaming_pull_async.result(timeout=pull_timeout)
except TimeoutError:
# Handle flow timeout
pass
```

example publish:

```python
topic_path = f"projects/{project_id}/topics/{output_topic}"
publish_value_async = publisher.publish_async(topic_path, value)
await publish_value_async.result()
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。