I store in cash connection:
# покажем если был вызов а не из кэша
def conn_1(curr, xcurr):
print 'try connect to ',curr.abbrev
# def __init__(self, service_url, service_name=None, timeout=HTTP_TIMEOUT,
connection=None):
cn = ServiceProxy(xcurr.connect_url, None, 40)
#print cn
blk = cn.getblockcount()
print 'connected on block:', blk
return cn
# тут если удача то надолго запомним
def conn_0(curr, xcurr):
try:
cn = cache.ram(curr.abbrev, lambda: conn_1(curr, xcurr), time_expire =
36000)
except Exception as e:
print curr.abbrev + ' conn except: %s' %
str(e).decode('cp1251','replace')
cn = None
if not cn:
cache.ram.clear(curr.abbrev)
return cn
# если нет связи то тоже запомним на небольшое время
def conn(curr, xcurr, cn=None):
# пока не подключимся - пробуем
cn = cache.ram(curr.abbrev + '_0', lambda: conn_0(curr, xcurr), time_expire
= 10)
return cn
Traceback (most recent call last):
File "C:\web2py-m\gluon\restricted.py", line 224, in restricted
exec ccode in environment
File "C:/web2py-m/applications/shop/controllers/appadmin.py"
<http://127.0.0.1:8000/admin/default/edit/shop/controllers/appadmin.py>, line
636, in <module>
File "C:\web2py-m\gluon\globals.py", line 393, in <lambda>
self._caller = lambda f: f()
File "C:/web2py-m/applications/shop/controllers/appadmin.py"
<http://127.0.0.1:8000/admin/default/edit/shop/controllers/appadmin.py>, line
371, in ccache
cache.disk.clear()
File "C:\web2py-m\gluon\cache.py", line 427, in clear
storage.clear()
File "C:\web2py-m\gluon\cache.py", line 364, in clear
for key in self:
File "C:\web2py-m\gluon\cache.py", line 349, in __iter__
yield self.key_filter_out(filename)
File "C:\web2py-m\gluon\cache.py", line 307, in key_filter_out_windows
return base64.b32decode(key)
File "C:\Python27\lib\base64.py", line 198, in b32decode
raise TypeError('Incorrect padding')
TypeError: Incorrect padding
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.