Skip to content

Commit 2a93d6b

Browse files
authored
Merge pull request #1581 from aftersnow/fix-high-cpu-usage
Fix high cpu usage caused by fd leak
2 parents 8c81ee1 + 9ed8069 commit 2a93d6b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

supervisor/supervisord.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ def runforever(self):
222222
raise
223223
except:
224224
combined_map[fd].handle_error()
225+
else:
226+
# if the fd is not in combined_map, we should unregister it. otherwise,
227+
# it will be polled every time, which may cause 100% cpu usage
228+
self.options.logger.warn('unexpected read event from fd %r' % fd)
229+
try:
230+
self.options.poller.unregister_readable(fd)
231+
except:
232+
pass
225233

226234
for fd in w:
227235
if fd in combined_map:
@@ -237,6 +245,12 @@ def runforever(self):
237245
raise
238246
except:
239247
combined_map[fd].handle_error()
248+
else:
249+
self.options.logger.warn('unexpected write event from fd %r' % fd)
250+
try:
251+
self.options.poller.unregister_writable(fd)
252+
except:
253+
pass
240254

241255
for group in pgroups:
242256
group.transition()

0 commit comments

Comments
 (0)