On 13 January 2014 13:07, Victor Stinner <[email protected]> wrote:

> Hi,
>
> 2014/1/13 Gustavo Carneiro <[email protected]>:
> > Here you can find a small module I made to monkey-patch some of the
> Ghost.py
> > methods to make them cooperative with Tulip:
> >
> > http://pastebin.com/sveXBpjK
> >
> > Maybe it will be useful to someone else.
> >
> > Ghost.py is a python module that implements a headless web browser, using
> > Qt4: https://pypi.python.org/pypi/Ghost.py
>
> When I read "Qt" I expect that you use Qt event loop in Tulip, but
> your monkey-patch is only a partial patch to use Tulip for some
> functions.
>
> I see that you use polling in wait_for() (with sleep of 10 ms).
> Polling is inefficient. You should try to use a future and wait for
> the future completion instead. For example, wait_for_page_loaded()
> would complete the future when the page is loaded. The problem is to
> see how to patch Ghost to call a method when loaded attribute value
> changes :-)


Hi Victor.

Not that I disagree with you.  However, to put things  in perspective, the
polling with 10ms sleep approach is already in upstream Ghost.py.  I merely
made it use asyncio sleep instead of time.sleep().

About returning a Future, the thing is easier implemented as a co-routine.
 It is less expensive to return it as co-routine, and the caller can
convert it into a future if it needs to, though most often the caller will
just use yield from.

Indeed it would be interesting to be able to run the Qt main loop through
Tulip, but that's a project I don't want to take on.  I only want to be
able to run Ghost.py in Tulip, even if it is slightly inneficient.  If
someone else does the work of integrating Qt into Tulip, I would be
interested in adapting Ghost.py to make use of this integration.

Thanks.

-- 
Gustavo J. A. M. Carneiro
Gambit Research LLC
"The universe is always one step beyond logic." -- Frank Herbert

Reply via email to