kopia lustrzana https://github.com/hholzgra/ocitysmap
Set statement_timeout for DB connections
The patch sets the statement_timeout parameter for the ocitysmap sessions to 18mn. This should be enough. I checked that an exception is raised when the timeout appears (=> ocitysmap crashes immediatly). The other sessions (eg. osm2pgsql) should not be affected. Issue "show statement_timeout" on a new DB connection to make sure (should reply '0'). This is a "quick and dirty fix": the timeout should be configurable from a config file or from the cmdline. For now it's hard-coded in street_index.py. Patch by David Decotigny <d2@maposmatic.org>stable
rodzic
02a09c76de
commit
696e32f398
|
|
@ -32,6 +32,7 @@ import map_canvas, grid, utils
|
|||
from draw_utils import enclose_in_frame
|
||||
|
||||
LOG = logging.getLogger('ocitysmap')
|
||||
STATEMENT_TIMEOUT_MINUTES = 18
|
||||
|
||||
class BaseOCitySMapError(Exception):
|
||||
"""Base class for exceptions thrown by OCitySMap."""
|
||||
|
|
@ -294,6 +295,16 @@ class OCitySMap:
|
|||
datasource['password'], datasource['host'],
|
||||
datasource['dbname'])
|
||||
|
||||
# Set session timeout parameter (18mn)
|
||||
cursor = db.cursor()
|
||||
cursor.execute("show statement_timeout;")
|
||||
LOG.debug("Initial statement timeout: %s" % cursor.fetchall()[0][0])
|
||||
cursor.execute("set session statement_timeout=%d;"
|
||||
% (STATEMENT_TIMEOUT_MINUTES*60*1000))
|
||||
cursor.execute("show statement_timeout;")
|
||||
LOG.info("Configured statement timeout: %s" % cursor.fetchall()[0][0])
|
||||
del cursor
|
||||
|
||||
if self.city_name:
|
||||
self.boundingbox = self.find_bounding_box_by_name(db, self.city_name)
|
||||
elif self.osmid:
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue