]> git.openstreetmap.org Git - nominatim.git/commitdiff
reintroduce timeout for replication file download
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 4 Feb 2021 10:47:11 +0000 (11:47 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 4 Feb 2021 10:47:11 +0000 (11:47 +0100)
This ports the --socket-timeout parameter from
pyosmium-get-changes which ensures that the update
process eventually times out on hanging network connections.

nominatim/cli.py

index 722022b500c13a514c12448c6520a221ed22f317..e28ff29563f8edf9df2adef1a786f612520922a7 100644 (file)
@@ -4,6 +4,7 @@ database administration and querying.
 """
 import datetime as dt
 import os
+import socket
 import sys
 import time
 import argparse
@@ -261,11 +262,16 @@ class UpdateReplication:
                                    together with --once""")
         group.add_argument('--osm2pgsql-cache', metavar='SIZE', type=int,
                            help='Size of cache to be used by osm2pgsql (in MB)')
+        group = parser.add_argument_group('Download parameters')
+        group.add_argument('--socket-timeout', dest='socket_timeout', type=int, default=60,
+                           help='Set timeout for file downloads.')
 
     @staticmethod
     def _init_replication(args):
         from .tools import replication, refresh
 
+        socket.setdefaulttimeout(args.socket_timeout)
+
         LOG.warning("Initialising replication updates")
         conn = connect(args.config.get_libpq_dsn())
         replication.init_replication(conn, base_url=args.config.REPLICATION_URL)