Skip to content

Instantly share code, notes, and snippets.

@beltran
Created March 9, 2017 22:55
Show Gist options
  • Save beltran/67495a0e7a2d24204c9b9263a5dd9019 to your computer and use it in GitHub Desktop.
Save beltran/67495a0e7a2d24204c9b9263a5dd9019 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import os
import uuid
import time
import dse
from dse import cluster as cassandra_cluster
#from dse.io.geventreactor import GeventConnection
from dse.io.eventletreactor import EventletConnection
from dse.io.libevreactor import LibevConnection
from dse.io.asyncorereactor import AsyncoreConnection
from dse.concurrent import execute_concurrent
import concurrent
import os
import resource
from itertools import cycle
import gc
import logging
log = logging.getLogger()
handler = logging.StreamHandler()
logFormatter = logging.Formatter("[%(levelname)s] %(asctime)s %(name)s %(thread)d: %(message)s")
logging.basicConfig(datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.DEBUG)
handler.setFormatter(logFormatter)
log.addHandler(handler)
connection_class=EventletConnection
import code
import signal
if connection_class == EventletConnection:
from eventlet import monkey_patch
monkey_patch()
signal.signal(signal.SIGUSR2, lambda sig, frame: code.interact())
local_pid = os.getpid()
#cluster = cassandra_cluster.Cluster(("127.0.0.1", "127.0.0.2", "127.0.0.3",), connection_class=LibevConnection)
cluster = cassandra_cluster.Cluster(("127.0.0.1", "127.0.0.2", "127.0.0.3"), connection_class=connection_class)
session = cluster.connect()
session.execute('''
CREATE KEYSPACE IF NOT EXISTS test3rf
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}''')
session.execute('''
CREATE TABLE IF NOT EXISTS test3rf.test (
k int PRIMARY KEY,
v int )''')
count = 0
print("Starting iterations")
while 1:
time.sleep(0.0001)
count = count + 1
if not count % 1:
pass
#print(resource.getrusage(resource.RUSAGE_SELF))
if not count % 100:
print("Hey")
print("The end")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment