Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding basic instrumentation

  • Loading branch information...
commit c155e124fa7ef4b0c6230e11b06cca2b3229799d 1 parent baace55
Jason Baker authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 shrapnel/instrument.py
View
21 shrapnel/instrument.py
@@ -0,0 +1,21 @@
+import threading, time, os, sys
+
+class ProfilingThread(threading.Thread):
+ daemon = True
+ def __init__(self, ioloop):
+ self.ioloop = ioloop
+ threading.Thread.__init__(self)
+
+ def run(self):
+ pid = os.getpid()
+ outfile_path = os.path.abspath('profdata-{0}.log'.format(pid))
+ print outfile_path
+ sys.stdout.flush()
+ outfile = open(outfile_path, 'w')
+ while True:
+ handler_len = len(self.ioloop._handlers)
+ event_len = len(self.ioloop._events)
+ callback_len = len(self.ioloop._callbacks)
+ print >> outfile, ', '.join([str(time.time()), str(handler_len), str(event_len), str(callback_len)])
+ outfile.flush()
+ time.sleep(5)
Please sign in to comment.
Something went wrong with that request. Please try again.