Re: [libvirt] Help needed: simple python api to obtain events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 09, 2009 at 02:01:13PM +0200, Dan Kenigsberg wrote:
> On Fri, Oct 09, 2009 at 09:58:14AM +0100, Daniel P. Berrange wrote:
> > On Fri, Oct 09, 2009 at 10:19:08AM +0200, Dan Kenigsberg wrote:
> > > On Wed, Oct 07, 2009 at 12:59:39PM +0100, Daniel P. Berrange wrote:
> > > > On Tue, Oct 06, 2009 at 07:04:29PM +0200, Dan Kenigsberg wrote:
> > > > > Would someone help me have a shrink-wrapped solution for obtaining libvirt
> > > > > events in python?
> > > > 
> > > > I decided to re-write the demo program so that is shows a serious
> > > > production kwalitee event loop implementation that can be used in
> > > > real world applications. I think you'll find this much nicer :-)
> > > 
> > > It sure look nicer (though I still don't get the hows and whys).
> > > However, it seems that you have an issue with python's time.time()
> > > measured in seconds, not milliseconds.
> > 
> > Here's a version with more docs & the time in milliseconds

> >     def run_once(self):
> >         sleep = -1
> >         next = self.next_timeout()
> >         self.debug("Next timeout due at %d" % next)
> >         if next > 0:
> >             now = int(time.time() * 1000)
> >             if now >= next:
> >                 sleep = 0
> >             else:
> >                 sleep = next - now
> > 
> >         self.debug("Poll with a sleep of %d" % sleep)
> >         events = self.poll.poll(sleep)
> 
> Thanks! but there's still a units problem here (should be sleep/1000. )

I fixed that too and pushed the example update to GIT

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]