/
poll.py
executable file
·47 lines (32 loc) · 931 Bytes
/
poll.py
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
46
47
#!/usr/bin/python
import time
import threading
from pbl.config import getcfg
from pbl.database import Database
from pbl import pollers
from pbl.pollers import POLLERS
from pbl.parser.parserthread import ParserThread
def main():
proxy = getcfg('http_proxy')
if proxy:
print 'Using http proxy %s' % (proxy, )
pollers.requestoptions['proxies'] = {'http': proxy, 'https': proxy}
try:
threading.stack_size(512 * 1024)
except BaseException as e:
print 'Error changing stack size:', repr(e)
# Connect to the database...
Database.get()
parser = ParserThread()
parser.start()
for poller in POLLERS.values():
poller.start()
# wait for them to finish!
for poller in POLLERS.values():
while poller.is_alive():
time.sleep(1)
while parser.is_alive():
time.sleep(1)
return
if __name__ == '__main__':
main()