Skip to content

Instantly share code, notes, and snippets.

@dbishop
Created September 27, 2012 01:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbishop/7a2e224f3aafea1a1fc3 to your computer and use it in GitHub Desktop.
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?!
#!/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()
--- 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):
@temoto
Copy link

temoto commented Jan 4, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment