-
-
Save dbishop/7a2e224f3aafea1a1fc3 to your computer and use it in GitHub Desktop.
At least on Ubuntu, this script will get into an infinite loop and chew up all your CPU. Sweet?!
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
#!/usr/bin/env python | |
import traceback | |
import subprocess | |
import eventlet | |
from eventlet.green import socket | |
def _spammer(address, xid): | |
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) | |
sock.connect(address) | |
for i in xrange(10000): | |
msg = '<13>message %d from %s' % (i, xid) | |
try: | |
sock.send(msg) | |
except socket.error: | |
traceback.print_exc() | |
def _restarter(sleep_time): | |
eventlet.sleep(sleep_time) | |
subprocess.call('sudo restart rsyslog', shell=True) | |
pool = eventlet.GreenPool(11) | |
for i in xrange(10): | |
pool.spawn_n(_spammer, '/dev/log', i) | |
pool.spawn_n(_restarter, 0.01) | |
pool.waitall() |
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
--- eventlet/greenio.py 2012-09-26 18:31:08.095164541 -0700 | |
+++ eventlet/greenio.py.patched 2012-09-26 18:30:53.843498109 -0700 | |
@@ -63,8 +63,8 @@ | |
else: | |
# oddly, on linux/darwin, an unconnected socket is expected to block, | |
# so we treat ENOTCONN the same as EWOULDBLOCK | |
- SOCKET_BLOCKING = set((errno.EWOULDBLOCK, errno.ENOTCONN)) | |
- SOCKET_CLOSED = set((errno.ECONNRESET, errno.ESHUTDOWN, errno.EPIPE)) | |
+ SOCKET_BLOCKING = set((errno.EWOULDBLOCK,)) | |
+ SOCKET_CLOSED = set((errno.ECONNRESET, errno.ENOTCONN, errno.ESHUTDOWN, errno.EPIPE)) | |
def set_nonblocking(fd): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. I'm sorry for late reply.
I tried to reproduce your test without syslog and sudo and failed. Perhaps, you could help with it, so we would include test and fix into eventlet source to avoid regressions.
https://gist.github.com/temoto/8259860