From nobody Sun Feb 8 05:07:36 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 1491316318155834.7849422966699; Tue, 4 Apr 2017 07:31:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9952F787E7; Tue, 4 Apr 2017 14:31:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (unknown [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71B5B4F9E9; Tue, 4 Apr 2017 14:31:56 +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 29FBA5EC68; Tue, 4 Apr 2017 14:31:56 +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 v34EVnJo025045 for ; Tue, 4 Apr 2017 10:31:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id E7D7F9204A; Tue, 4 Apr 2017 14:31:49 +0000 (UTC) Received: from dhcp-17-113.lcy.redhat.com (unknown [10.42.17.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39A2E90C78; Tue, 4 Apr 2017 14:31:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9952F787E7 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.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 9952F787E7 From: "Daniel P. Berrange" To: libvir-list@redhat.com Date: Tue, 4 Apr 2017 15:31:33 +0100 Message-Id: <20170404143134.12141-7-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 6/7] event-test: rename example event loop impl 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 04 Apr 2017 14:31:57 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the name 'Poll' instead of 'Pure' for the event loop demo, since there's now a second pure python loop impl available. Signed-off-by: Daniel P. Berrange --- examples/event-test.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/event-test.py b/examples/event-test.py index ac9fbe1..e67984f 100755 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -39,10 +39,10 @@ def debug(msg): # # It is a pure python implementation based around the poll() API # -class virEventLoopPure: +class virEventLoopPoll: # This class contains the data we need to track for a # single file handle - class virEventLoopPureHandle: + class virEventLoopPollHandle: def __init__(self, handle, fd, events, cb, opaque): self.handle =3D handle self.fd =3D fd @@ -70,7 +70,7 @@ class virEventLoopPure: =20 # This class contains the data we need to track for a # single periodic timer - class virEventLoopPureTimer: + class virEventLoopPollTimer: def __init__(self, timer, interval, cb, opaque): self.timer =3D timer self.interval =3D interval @@ -142,14 +142,14 @@ class virEventLoopPure: =20 return next =20 - # Lookup a virEventLoopPureHandle object based on file descriptor + # Lookup a virEventLoopPollHandle object based on file descriptor def get_handle_by_fd(self, fd): for h in self.handles: if h.get_fd() =3D=3D fd: return h return None =20 - # Lookup a virEventLoopPureHandle object based on its event loop ID + # Lookup a virEventLoopPollHandle object based on its event loop ID def get_handle_by_id(self, handleID): for h in self.handles: if h.get_id() =3D=3D handleID: @@ -253,7 +253,7 @@ class virEventLoopPure: handleID =3D self.nextHandleID + 1 self.nextHandleID =3D self.nextHandleID + 1 =20 - h =3D self.virEventLoopPureHandle(handleID, fd, events, cb, opaque) + h =3D self.virEventLoopPollHandle(handleID, fd, events, cb, opaque) self.handles.append(h) =20 self.poll.register(fd, self.events_to_poll(events)) @@ -272,7 +272,7 @@ class virEventLoopPure: timerID =3D self.nextTimerID + 1 self.nextTimerID =3D self.nextTimerID + 1 =20 - h =3D self.virEventLoopPureTimer(timerID, interval, cb, opaque) + h =3D self.virEventLoopPollTimer(timerID, interval, cb, opaque) self.timers.append(h) self.interrupt() =20 @@ -361,7 +361,7 @@ class virEventLoopPure: =20 # This single global instance of the event loop wil be used for # monitoring libvirt events -eventLoop =3D virEventLoopPure() +eventLoop =3D virEventLoopPoll() =20 # This keeps track of what thread is running the event loop, # (if it is run in a background thread) @@ -371,7 +371,7 @@ eventLoopThread =3D None # These next set of 6 methods are the glue between the official # libvirt events API, and our particular impl of the event loop # -# There is no reason why the 'virEventLoopPure' has to be used. +# There is no reason why the 'virEventLoopPoll' has to be used. # An application could easily may these 6 glue methods hook into # another event loop such as GLib's, or something like the python # Twisted event framework. @@ -402,7 +402,7 @@ def virEventRemoveTimerImpl(timerID): =20 # This tells libvirt what event loop implementation it # should use -def virEventLoopPureRegister(): +def virEventLoopPollRegister(): libvirt.virEventRegisterImpl(virEventAddHandleImpl, virEventUpdateHandleImpl, virEventRemoveHandleImpl, @@ -411,7 +411,7 @@ def virEventLoopPureRegister(): virEventRemoveTimerImpl) =20 # Directly run the event loop in the current thread -def virEventLoopPureRun(): +def virEventLoopPollRun(): global eventLoop eventLoop.run_loop() =20 @@ -420,10 +420,10 @@ def virEventLoopNativeRun(): libvirt.virEventRunDefaultImpl() =20 # Spawn a background thread to run the event loop -def virEventLoopPureStart(): +def virEventLoopPollStart(): global eventLoopThread - virEventLoopPureRegister() - eventLoopThread =3D threading.Thread(target=3DvirEventLoopPureRun, nam= e=3D"libvirtEventLoop") + virEventLoopPollRegister() + eventLoopThread =3D threading.Thread(target=3DvirEventLoopPollRun, nam= e=3D"libvirtEventLoop") eventLoopThread.setDaemon(True) eventLoopThread.start() =20 @@ -684,7 +684,7 @@ def main(): =20 # Run a background thread with the event loop if use_pure_python_event_loop: - virEventLoopPureStart() + virEventLoopPollStart() else: virEventLoopNativeStart() =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list