-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug.py
More file actions
45 lines (37 loc) · 995 Bytes
/
debug.py
File metadata and controls
45 lines (37 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from netfilterqueue import NetfilterQueue
import threading
import psutil
import time
nfqueue=NetfilterQueue()
def PrintException():
exc_type, exc_obj, tb = sys.exc_info()
f = tb.tb_frame
lineno = tb.tb_lineno
filename = f.f_code.co_filename
linecache.checkcache(filename)
line = linecache.getline(filename, lineno, f.f_globals)
print 'EXCEPTION IN ({}, LINE {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj)
def control():
while True:
print psutil.cpu_percent(interval=1), psutil.phymem_usage().percent
print
time.sleep(10)
def print_and_accept(pkt):
#print pkt
pkt.accept()
def queue(coda):
print coda
nfqueue.bind(coda,print_and_accept)
nfqueue.run()
t=threading.Thread(target=control)
p1=threading.Thread(target=queue, args=(128,))
p2=threading.Thread(target=queue, args=(192,))
t.start()
print t.isAlive()
p1.start()
print p1.isAlive()
p2.start()
print p2.isAlive()
p1.join()
p2.join()
t.join()