From: Peter Eisentraut Date: Wed, 26 Jun 2019 21:28:06 +0000 (+0200) Subject: Make stress.py compatible with Python 3 X-Git-Tag: pgbouncer_1_10_0~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b5e3b7d1ecbbf093e433fa85ed33b8ac50fa502;p=pgbouncer Make stress.py compatible with Python 3 --- diff --git a/test/stress.py b/test/stress.py index 8796c3d..39f3e1d 100755 --- a/test/stress.py +++ b/test/stress.py @@ -6,7 +6,6 @@ import re import time import psycopg2 import threading -import thread import random n_thread = 100 @@ -62,8 +61,8 @@ class WorkThread(threading.Thread): break except SystemExit: break - except Exception, d: - print d + except Exception as d: + print(d) try: time.sleep(5) except Exception: @@ -89,7 +88,7 @@ class WorkThread(threading.Thread): def main(): - print "connstr", get_connstr() + print("connstr %s" % get_connstr()) thread_list = [] while len(thread_list) < n_thread: @@ -97,7 +96,7 @@ def main(): t.start() thread_list.append(t) - print "started %d threads" % len(thread_list) + print("started %d threads" % len(thread_list)) last = time.time() while 1: @@ -110,7 +109,7 @@ def main(): for t in thread_list: cnt += t.fetch_cnt() avg = cnt / dur - print "avg", avg + print("avg %s" % avg) if __name__ == '__main__': @@ -120,5 +119,5 @@ if __name__ == '__main__': pass except KeyboardInterrupt: pass - #except Exception, d: + #except Exception as d: # print d