Mercurial > hg > index.fcgi > www > www-1
comparison myrss/myrss_app.py @ 94:8214951cb8e7
myrss: additional logging
author | paulo |
---|---|
date | Fri, 16 Mar 2018 16:38:56 -0600 |
parents | 583400dc28a0 |
children | 259a484f691b |
comparison
equal
deleted
inserted
replaced
10:9c2dd6337045 | 11:7c46cfd8542c |
---|---|
7 import datetime | 7 import datetime |
8 import time | 8 import time |
9 import traceback | 9 import traceback |
10 | 10 |
11 import logging | 11 import logging |
12 logging.basicConfig( | 12 #logging.basicConfig( |
13 #level=logging.DEBUG, | 13 # level=logging.DEBUG, |
14 #filename="_LOG", | 14 # filename="_LOG", |
15 #format="%(asctime)s %(levelname)-8s %(message)s", | 15 # format="%(asctime)s %(levelname)-8s %(message)s", |
16 ) | 16 #) |
17 | 17 |
18 import xml.etree.ElementTree | 18 import xml.etree.ElementTree |
19 import HTMLParser | 19 import HTMLParser |
20 | 20 |
21 import html | 21 import html |
215 | 215 |
216 def main(input_queue, output_queue, lock): | 216 def main(input_queue, output_queue, lock): |
217 ret = '' | 217 ret = '' |
218 | 218 |
219 with lock: | 219 with lock: |
220 logging.debug("main() started") | |
220 epoch_now = time.time() | 221 epoch_now = time.time() |
221 dtnow = datetime.datetime.fromtimestamp(epoch_now) | 222 dtnow = datetime.datetime.fromtimestamp(epoch_now) |
222 | 223 |
223 if os.path.exists(CACHE_HTML_FILE) and (epoch_now - os.stat(CACHE_HTML_FILE).st_mtime) < float(CACHE_LIFE): | 224 if os.path.exists(CACHE_HTML_FILE) and (epoch_now - os.stat(CACHE_HTML_FILE).st_mtime) < float(CACHE_LIFE): |
224 with open(CACHE_HTML_FILE) as cache_html_file: | 225 with open(CACHE_HTML_FILE) as cache_html_file: |
248 return ret | 249 return ret |
249 | 250 |
250 | 251 |
251 class MyRssApp: | 252 class MyRssApp: |
252 def __init__(self): | 253 def __init__(self): |
254 logging.debug("MyRssApp.__init__() called") | |
253 self._iq = Queue.Queue(MAX_THREADS) | 255 self._iq = Queue.Queue(MAX_THREADS) |
254 self._oq = Queue.Queue(MAX_THREADS) | 256 self._oq = Queue.Queue(MAX_THREADS) |
255 self._main_lock = threading.Lock() | 257 self._main_lock = threading.Lock() |
256 | 258 |
257 for _ in range(MAX_THREADS): | 259 for i in range(MAX_THREADS): |
260 logging.debug("Starting thread: %d" % i) | |
258 WorkerThread(input_queue=self._iq, output_queue=self._oq).start() | 261 WorkerThread(input_queue=self._iq, output_queue=self._oq).start() |
259 | 262 |
260 def __call__(self, environ, start_response): | 263 def __call__(self, environ, start_response): |
261 response_code = "500 Internal Server Error" | 264 response_code = "500 Internal Server Error" |
262 response_type = "text/plain; charset=UTF-8" | 265 response_type = "text/plain; charset=UTF-8" |