-
-
Save raybotha/2d9d1119f1436ff34071d4ce3a041f51 to your computer and use it in GitHub Desktop.
Monkeypatched single thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import pubsub_v1 | |
from time import sleep | |
import eventlet | |
eventlet.monkey_patch() | |
publisher = pubsub_v1.PublisherClient() | |
topic_path = publisher.topic_path("project123", "topic123") | |
def process_message(msg): | |
publisher.publish(topic_path, data=msg.encode("utf-8")) | |
for i in range(1000): | |
process_message(str(i)) | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to apply the monkey patch before imports, otherwise it doesn't take effect