[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r16954: {weather} Update the __main__ to handle gdbm open failures in a more g (weather/trunk)
Author: ioerror
Date: 2008-09-24 01:53:37 -0400 (Wed, 24 Sep 2008)
New Revision: 16954
Modified:
weather/trunk/weather.py
Log:
Update the __main__ to handle gdbm open failures in a more graceful manner. And add a small note about where we're going to extend things. This is slowly progressing towards finding the nasty deadlock that I've been digging for. It's not fixed yet...grrr.
Modified: weather/trunk/weather.py
===================================================================
--- weather/trunk/weather.py 2008-09-24 03:30:14 UTC (rev 16953)
+++ weather/trunk/weather.py 2008-09-24 05:53:37 UTC (rev 16954)
@@ -33,28 +33,33 @@
# This is a single lock for all the gdbm write rights, to ensure that
# different web.py threads aren't trying to write at the same time.
+
+ try:
- gdbm_lock = threading.RLock()
+ gdbm_lock = threading.RLock()
- requests = gdbm.open(weather_storage + "/requests.gdbm","cs")
- print "requests:"
- for s in requests.keys():
- print s, requests[s]
- subscriptions = gdbm.open(weather_storage + "/subscriptions.gdbm","cs")
- print "subscriptions:"
- for s in subscriptions.keys():
- print s, '"'+subscriptions[s]+'"'
- unsubscriptions = gdbm.open(weather_storage + "/unsubscriptions.gdbm","cs")
- print "unsubscriptions:"
- for s in unsubscriptions.keys():
- print s, unsubscriptions[s]
+ requests = gdbm.open(weather_storage + "/requests.gdbm","cs")
+ print "requests:"
+ for s in requests.keys():
+ print s, requests[s]
+ subscriptions = gdbm.open(weather_storage + "/subscriptions.gdbm","cs")
+ print "subscriptions:"
+ for s in subscriptions.keys():
+ print s, '"'+subscriptions[s]+'"'
+ unsubscriptions = gdbm.open(weather_storage + "/unsubscriptions.gdbm","cs")
+ print "unsubscriptions:"
+ for s in unsubscriptions.keys():
+ print s, unsubscriptions[s]
- antispam_lock = threading.RLock()
- antispam = {} # a dict mapping IP to the number of recent unanswered requests allowed
- # from that IP
- antispam_min = 2
- antispam_max = 10
+ antispam_lock = threading.RLock()
+ antispam = {} # a dict mapping IP to the number of recent unanswered requests allowed
+ # from that IP
+ antispam_min = 2
+ antispam_max = 10
+ except:
+ print "Unable to get lock on database"
+
# these may or may not be better than storing pickles with gdbm
class DatabaseError(Exception):
@@ -111,6 +116,10 @@
print open("subscribe.template").read()
whitespace = re.compile("\s*")
+ # XXX TODO: I think this is where we want to add new form values
+ # Specifically, we want to allow 'nickname' and 'nodenote'
+ # These strings are 50 chars max and should only allow [a-zA-Z0-9.,]
+ # Once we add this, we want to add some method of storing this user input
def POST(self):
web.header('content-type', 'text/html')
i = web.input(node="none",email="none")