Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions saphyra.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,24 @@ def __init__(self, url):

def exit(self):
self.stats()
print "Shutting down Saphyra"
print("Shutting down Saphyra")

def __del__(self):
self.exit()

def printHeader(self):

print
print
print()
print()

# Do the fun!
def fire(self):

self.printHeader()
print "MODE: '{0}' - WORKERS: {1} - CONNECTIONS: {2} ".format(self.method, self.nr_workers, self.nr_sockets)
print("MODE: '{0}' - WORKERS: {1} - CONNECTIONS: {2} ".format(self.method, self.nr_workers, self.nr_sockets))

if DEBUG:
print "Starting {0} concurrent workers".format(self.nr_workers)
print("Starting {0} concurrent workers".format(self.nr_workers))

# Start workers
for i in range(int(self.nr_workers)):
Expand All @@ -96,18 +96,18 @@ def fire(self):
pass

if DEBUG:
print "Initiating monitor"
print("Initiating monitor")
self.monitor()

def stats(self):

try:
if self.counter[0] > 0 or self.counter[1] > 0:

print "{0} Saphyra strikes deferred. ({1} Failed)".format(self.counter[0], self.counter[1])
print("{0} Saphyra strikes deferred. ({1} Failed)".format(self.counter[0], self.counter[1]))

if self.counter[0] > 0 and self.counter[1] > 0 and self.last_counter[0] == self.counter[0] and self.counter[1] > self.last_counter[1]:
print "\tServer may be DOWN!"
print("\tServer may be DOWN!")

self.last_counter[0] = self.counter[0]
self.last_counter[1] = self.counter[1]
Expand All @@ -130,7 +130,7 @@ def monitor(self):
for worker in self.workersQueue:
try:
if DEBUG:
print "Killing worker {0}".format(worker.name)
print("Killing worker {0}".format(worker.name))
#worker.terminate()
worker.stop()
except Exception, ex:
Expand Down Expand Up @@ -222,7 +222,7 @@ def buildblock(self, size):
def run(self):

if DEBUG:
print "Starting worker {0}".format(self.name)
print("Starting worker {0}".format(self.name))

while self.runnable:

Expand Down Expand Up @@ -260,7 +260,7 @@ def run(self):
pass # silently ignore

if DEBUG:
print "Worker {0} completed run. Sleeping...".format(self.name)
print("Worker {0} completed run. Sleeping...".format(self.name))

def closeConnections(self):
for conn in self.socks:
Expand Down Expand Up @@ -441,9 +441,9 @@ def incFailed(self):
pass

def usage():
print 'Usage: Saphyra (url)'
print 'Example: Saphyra.py http://luthi.co.il/'
print "\a"
print('Usage: Saphyra (url)')
print ('Example: Saphyra.py http://luthi.co.il/')
print ("\a")
print \
"""

Expand Down