[Yum-devel] [UG] CTRL-C wierdness revisited

Menno Smits menno-yum at freshfoo.com
Tue Jun 28 10:13:28 UTC 2005


Michael Stenner wrote:

>>    - add an "interrupt" callback to urlgrabber or allow client code to
>>      abort a running urlgrabber transfer when it receives external
>>      events (GUIs should be considered here too)
> 
> 
> Not sure I follow yet.  Can you send some example code (even if a bit
> hackish) that demonstrates the kind of changes you want to make to yum
> and urlgrabber?  

Ok, see attached patch and demo script. This isn't my original hack but 
the idea is similar and the code is cleaner. It adds an interrupt 
callback which allows the client code to decide how to handle CTRL-C's 
and tell urlgrabber how to proceed.

The demo script starts a download using a list of mirrors. CTRL-C once 
jumps to the next mirror. Two CTRL-C's within 0.5 seconds will allow the 
KeyboardInterrupt to be passed through and stop everything.

Of course this idea won't work within Yum until we get the rpm SIGINT 
issue sorted but you get idea. It _does_ work within Yum if you convert 
socket.error errno 11 within urlgrabber to a KeyboardInterrupt. This is 
what my original hack did. Many little changes where-ever socket.error 
is caught in urlgrabber.

> "crudly"...  I like it :)  Can we see?

That was a typo but it kinda worked out nicely :)


Menno
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrlc_demo.py
Type: text/x-python
Size: 1643 bytes
Desc: not available
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20050628/f55fdb91/attachment.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ug_interrupt_cb.patch
Type: text/x-patch
Size: 1230 bytes
Desc: not available
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20050628/f55fdb91/attachment.bin 


More information about the Yum-devel mailing list