[Buildbot-devel] BuildStep: Calling a function repeatedly until it returns correct value
Pierre Tardy
tardyp at gmail.com
Tue Nov 20 12:46:55 UTC 2012
At first glance, what you need is reactor.callLater(interval, lambda
:poll_up(interval, marching_criteria))
However, I would guess the you get_ip function is also doing blocking IO,
so probably you want to also write this part in asynchronous. In that case,
you'll need to dive much more into twisted
Pierre
On Tue, Nov 20, 2012 at 1:26 PM, Edward Ekelund <edward.ekelund at axis.com>wrote:
> Hello,
>
> During a certain step in the build process I need to call on an external
> python method that will query a server for an ip address matching
> certain criteria. Let's call it get_ip(criteria).
>
> get_ip() will either return the ip address or a flag indicating that all
> addresses matching the criteria are currently busy.
>
> If all addresses are busy I don't want the current step to continue -- I
> want it to poll get_ip(criteria) every x minutes until an ip becomes
> available and thus can be returned.
>
> My first naive approach was to set up a polling method and call it
> instead, i.e:
>
> def poll_ip(interval, matching_criteria):
> ip = get_ip(matching_criteria)
> if ip == "busy":
> time.sleep(interval)
> ip = get_ip(matching_criteria)
> return ip
>
> This doesn't work at all. In fact, the call to time.sleep() locks the
> whole buildbot process so that nothing can be done until get_ip stops
> returning busy. Not even the web-gui is working. Not good.
>
> I realize I will have to utilize twisted somehow to call get_ip()
> asynchronously, and repeatedly if necessary. I am new to asynchronous
> programming and twisted, and none of my feeble attempts have worked,
> however.
>
> I feel it shouldn't be that difficult. Does anyone here know of a good
> solution to my problem?
>
> Thanks,
> Eddie
>
>
>
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20121120/ac6b68e0/attachment.html>
More information about the devel
mailing list