]> git.openstreetmap.org Git - nominatim.git/commitdiff
nominatim.py: use async in connect() function
authorSarah Hoffmann <lonvia@denofr.de>
Tue, 11 Feb 2020 21:08:04 +0000 (22:08 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Tue, 11 Feb 2020 21:16:17 +0000 (22:16 +0100)
The _async parameter name is only supported since psycopg 2.7.
However, async is a keyword in Python >= 3.7, so using this
gives us a syntax error. Working around this by defining the
parameters in a dict and handing that into the connect function.

nominatim/nominatim.py

index ac6d23ffb070c41744e178b6c0e14124d2ef5f9f..14643770a6642662be283b0d21b3d36b556ac407 100755 (executable)
@@ -35,9 +35,14 @@ import select
 log = logging.getLogger()
 
 def make_connection(options, asynchronous=False):
-    return psycopg2.connect(dbname=options.dbname, user=options.user,
-                            password=options.password, host=options.host,
-                            port=options.port, async_=asynchronous)
+    params = {'dbname' : options.dbname,
+              'user' : options.user,
+              'password' : options.password,
+              'host' : options.host,
+              'port' : options.port,
+              'async' : asynchronous}
+
+    return psycopg2.connect(**params)
 
 
 class RankRunner(object):