From nobody Sun Feb 8 03:58:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1491316311587172.63201469670094; Tue, 4 Apr 2017 07:31:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0F30F1293; Tue, 4 Apr 2017 14:31:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA63E7E4FF; Tue, 4 Apr 2017 14:31:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 62C935EC64; Tue, 4 Apr 2017 14:31:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v34EVlfO025020 for ; Tue, 4 Apr 2017 10:31:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55D0C8EF4C; Tue, 4 Apr 2017 14:31:47 +0000 (UTC) Received: from dhcp-17-113.lcy.redhat.com (unknown [10.42.17.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9B934F9E9; Tue, 4 Apr 2017 14:31:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D0F30F1293 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D0F30F1293 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 15:31:31 +0100 Message-Id: <20170404143134.12141-5-berrange@redhat.com> In-Reply-To: <20170404143134.12141-1-berrange@redhat.com> References: <20170404143134.12141-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Wojtek Porczyk Subject: [libvirt] [PATCH v3 4/7] event-test: add timeout to exit event loop X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 04 Apr 2017 14:31:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Daniel P. Berrange --- examples/event-test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/event-test.py b/examples/event-test.py index 851c09b..751a140 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -651,15 +651,17 @@ def usage(): print(" --help, -h Print(this help message") print(" --debug, -d Print(debug output") print(" --loop, -l Toggle event-loop-implementation") + print(" --timeout=3DSECS Quit after SECS seconds running") =20 def main(): try: - opts, args =3D getopt.getopt(sys.argv[1:], "hdl", ["help", "debug"= , "loop"]) + opts, args =3D getopt.getopt(sys.argv[1:], "hdl", ["help", "debug"= , "loop", "timeout=3D"]) except getopt.GetoptError as err: # print help information and exit: print(str(err)) # will print something like "option -a not recogni= zed" usage() sys.exit(2) + timeout =3D None for o, a in opts: if o in ("-h", "--help"): usage() @@ -670,6 +672,8 @@ def main(): if o in ("-l", "--loop"): global use_pure_python_event_loop use_pure_python_event_loop ^=3D True + if o in ("--timeout"): + timeout =3D int(a) =20 if len(args) >=3D 1: uri =3D args[0] @@ -741,7 +745,9 @@ def main(): # of demo we'll just go to sleep. The other option is to # run the event loop in your main thread if your app is # totally event based. - while run: + count =3D 0 + while run and (timeout is None or count < timeout): + count =3D count + 1 time.sleep(1) =20 =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list