Revolution1 / etcd3-py

Pure python client for etcd v3 (Using gRPC-JSON-Gateway)
Other
105 stars 25 forks source link

Does long running lead to high loads with ‘Watcher() API’ #118

Closed boylegu closed 4 years ago

boylegu commented 4 years ago

etcd3-py version: 0.1.6 Python version: 3.7.4 Operating System: centos 7

Description

I found that using "Watcher() API" single cpu is achieved 100%. I don't know how to optimize. Such as ‘process of pool’? My code is simple, as follows:

What I Did

# sit_watcher.py

def doSomething():
    .....

def WatchAllAgentService():
    client = Client()
    watcher = client.Watcher(all=True, progress_notify=True, prev_kv=True)
    watcher.onEvent('/health/', doSomething)
    watcher.runDaemon()

WatchAllAgentService()

while True:
    pass
> ps auwx|grep python
root     31454 95.6 84.2 3711376 3242992 ?     R    11月11 20786:29 python sit_watcher.py
issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label question to this issue, with a confidence of 0.92. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Revolution1 commented 4 years ago

uh...

try this:

while True:
    pass
boylegu commented 4 years ago

Oh! I know it's stupid. Maybe should instead of Supervisor

boylegu commented 4 years ago
while True:
    time.sleep(1)

It seems to be working well