Mic92 / python-mpd2

Python library which provides a client interface for the Music Player Daemon.
GNU Lesser General Public License v3.0
352 stars 119 forks source link

How to avoid the large flow in the infinite loop #215

Closed Ocyss closed 1 year ago

Ocyss commented 1 year ago

I plan to display the lyrics in my bar, so I wrote an infinite loop to get the current time, and then query the corresponding words to print.

But I found that the traffic ran to 50MB/s, and I don't know how to avoid it. I think ncmpcpp should also read more frequently. I don't know how they communicate. I read the documentation of mpd2, but it didn't solve my problem.

Mic92 commented 1 year ago

Can you not synchronize the time in the client and only infrequently update the time from mpd for synchronization?

Ocyss commented 1 year ago

I currently use two threads, one to output the lyrics in an infinite loop, and the other to get the time + process the current lyrics in an infinite loop, but add a sleep of 0.5 seconds, this problem is solved.