Skip to content

Instantly share code, notes, and snippets.

@beltran
Created March 7, 2017 22:26
Show Gist options
  • Save beltran/14a64ac5be26f568fa652a76dda30ce0 to your computer and use it in GitHub Desktop.
Save beltran/14a64ac5be26f568fa652a76dda30ce0 to your computer and use it in GitHub Desktop.
POC for socket bug
# -*- coding: utf-8 -*-
import os
import uuid
import time
import cassandra
from cassandra import cluster as cassandra_cluster
#from cassandra.io.geventreactor import GeventConnection
from cassandra.io.eventletreactor import EventletConnection
from cassandra.io.libevreactor import LibevConnection
from cassandra.io.asyncorereactor import AsyncoreConnection
connection_class=EventletConnection
if connection_class == EventletConnection:
from eventlet import monkey_patch
monkey_patch()
cluster = cassandra_cluster.Cluster(("127.0.0.1", "127.0.0.2", "127.0.0.3"), connection_class=connection_class)
local_pid = os.getpid()
def logstatus(i, msg):
return # comment out if need status log
with open("/tmp/logstatus.txt", "w") as fp:
fp.write(str(i) + msg + "\n")
print(str(i) + msg)
print(cassandra.cluster.__file__)
os.system("lsof -p "+str(local_pid)+" |grep -v 'REG' |grep -v 'DIR'")
for i in range(1000):
dbconn = cluster.connect("system")
logstatus(i, "... connected")
qresult = dbconn.execute("SELECT now() FROM system.paxos")
for row in qresult:
pass
logstatus(i, "... checked")
qresult = dbconn.execute("SELECT now() FROM system.paxos")
for row in qresult:
pass
dbconn.shutdown()
logstatus(i, "... disconnected")
if 0 == (i % 10):
print("---", i)
os.system("lsof -p "+str(local_pid)+" |grep -v 'REG' |grep -v 'DIR'")
print("===")
os.system("lsof -p "+str(local_pid)+" |grep -v 'REG' |grep -v 'DIR'")
print("---")
print("pid is")
print(local_pid)
while True:
time.sleep(10)
os.system("lsof -p "+str(local_pid)+" |grep -v 'REG' |grep -v 'DIR'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment