Too many open files error after using PubSub publisher on my local device

Viewed 222

While running a simple Pubsub application on my local computer, I had the following issue:

E0406 16:21:03.413811000 123146236731392 completion_queue.cc:1065]     Completion queue next failed: {"created":"@1586182863.413273000","description":"Too many open files","errno":24,"file":"src/core/lib/iomgr/wakeup_fd_pipe.cc","file_line":41,"os_error":"Too many open files","syscall":"pipe"}

Here is my code:

import time
import json
import time
import urllib.request
from google.cloud import pubsub_v1




def routine_pub(project_id, topic_name):

    # Initialize a Publisher client.
    client = pubsub_v1.PublisherClient()
    topic_path = client.topic_path(project_id, topic_name)


    for k in range(100000):
        api_future = client.publish(topic_path, data = json.dumps({"message": str(k)}).encode())
        print(str(k))



if __name__ == "__main__":

    routine_pub("my-project",  "my-topic")

The error arrived after the maximum number of opened filed quota on the OS was reached. I can't find an easy way to solve this problem.

pip3 freeze:

google-api-core==1.16.0
google-auth==1.13.1
google-cloud-pubsub==1.4.2
0 Answers
Related