plexflow 0.0.92__py3-none-any.whl → 0.0.93__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ from google.cloud import pubsub_v1
2
+ import json
3
+
4
+ def consume_message(topic_id: str, project_id: str, as_json: bool = True, timeout: int = 5):
5
+ subscriber = pubsub_v1.SubscriberClient()
6
+ # The `subscription_path` method creates a fully qualified identifier
7
+ # in the form `projects/{project_id}/subscriptions/{subscription_id}`
8
+ subscription_path = subscriber.subscription_path(project_id, topic_id)
9
+
10
+ data = None
11
+
12
+ def callback(message: pubsub_v1.subscriber.message.Message) -> None:
13
+ nonlocal data
14
+
15
+ print(f"Received {message}.")
16
+ print(message.data.decode())
17
+ if as_json:
18
+ data = json.loads(message.data.decode())
19
+ else:
20
+ data = message.data.decode()
21
+
22
+ message.ack()
23
+
24
+ streaming_pull_future = subscriber.subscribe(subscription_path, callback=callback)
25
+ print(f"Listening for messages on {subscription_path}..\n")
26
+
27
+ # Wrap subscriber in a 'with' block to automatically call close() when done.
28
+ with subscriber:
29
+ try:
30
+ # When `timeout` is not set, result() will block indefinitely,
31
+ # unless an exception is encountered first.
32
+ streaming_pull_future.result(timeout=timeout)
33
+ except TimeoutError:
34
+ streaming_pull_future.cancel() # Trigger the shutdown.
35
+ streaming_pull_future.result() # Block until the shutdown is complete.
36
+
37
+ return data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: plexflow
3
- Version: 0.0.92
3
+ Version: 0.0.93
4
4
  Summary: A short description of the package.
5
5
  License: MIT
6
6
  Keywords: keyword1,keyword2,keyword3
@@ -588,6 +588,7 @@ plexflow/utils/filesystem/search.py,sha256=ed2ixbx5r2z_xtk19--Dfi5KK9g3HcsaAk0sq
588
588
  plexflow/utils/gmail/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
589
589
  plexflow/utils/gmail/__pycache__/mails.cpython-311.pyc,sha256=FAYfZzjLVqpPMjrEYcrOIsohtWrZYYXOZSUHod3r8Qg,7239
590
590
  plexflow/utils/gmail/mails.py,sha256=hQIXiYR5LYeoiSH_lhbVM9criDBnTeCNmpZ5tvuUnsA,4562
591
+ plexflow/utils/google/pubsub/consume.py,sha256=MG4bW0D2s_38xO88b_3-K8PtknNCxPnCVtPtnQzoHgA,1408
591
592
  plexflow/utils/google/pubsub/produce.py,sha256=AFlf6QZl6owA4QNzgrmed-d8lFbhsy-0bnMVVbAGNt4,713
592
593
  plexflow/utils/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
593
594
  plexflow/utils/hooks/__pycache__/__init__.cpython-311.pyc,sha256=vlT8vFKsxMRss2XuHLM6ouyTl7Wk1To76MVYXowIABs,170
@@ -676,7 +677,7 @@ plexflow/utils/video/__pycache__/audio.cpython-312.pyc,sha256=vXBnJwWgTDFdixMBs-
676
677
  plexflow/utils/video/__pycache__/subtitle.cpython-312.pyc,sha256=PCjpCLydGXaRsQy6cikhgsEs8WlComfOoYPiLFqfVMA,2515
677
678
  plexflow/utils/video/audio.py,sha256=tJ_lNwcjVuBQYD5cYOlXpr__eh8-hnReIgNRgIYOpqo,3380
678
679
  plexflow/utils/video/subtitle.py,sha256=LOGONGxs_RzmqtGP-DBKreOzS1eUFEKo75Q6AfnavW0,1290
679
- plexflow-0.0.92.dist-info/METADATA,sha256=KFluh3UpTaNVM05w_Qw8GR51NlFT2NHPueEoQpkorz4,2953
680
- plexflow-0.0.92.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
681
- plexflow-0.0.92.dist-info/entry_points.txt,sha256=aEqDHlozu_zjWrl2sibtrqtQHMgU8kSJZrE782CP47g,1362
682
- plexflow-0.0.92.dist-info/RECORD,,
680
+ plexflow-0.0.93.dist-info/METADATA,sha256=OQlrJ20U88D_hDuRNKi1m4aOWdaXce0IRjObp9M8qUM,2953
681
+ plexflow-0.0.93.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
682
+ plexflow-0.0.93.dist-info/entry_points.txt,sha256=aEqDHlozu_zjWrl2sibtrqtQHMgU8kSJZrE782CP47g,1362
683
+ plexflow-0.0.93.dist-info/RECORD,,