can't flush I know why, but no fix

Ask a Question related to Ruby, Design and Development.

  1. #1

    Default Re: can't flush I know why, but no fix

    I figured out why it won't work. i'm using 1.8's open_uri to retrieve the url with open(url). as soon as this executes everything stops until it downloads the whole file! it isn't a real IO. blah! that stinks. not i wonder if net/http and net/ftp do the same since that's what oprn_uri is based on. if so then means i might have to get down to the socket level just to do a progess reported download. frig'n wonderful!

    If anyone knows of a better way, or a code snippet i can steal, Please let me know.

    Thanks,
    -t0

    T. Onoma Guest

  2. Similar Questions and Discussions

    1. Buffer Flush
      So, I'm trying to play streaming video from Dlash Media Server. nc = new NetConnection(); nc.connect('rtmp://mysite/myapp'); ns = new...
    2. Flush right type not flush
      With Illustrator CS in Win XP, my flush right lines of type are not cleanly aligned on the right (using Gill Sans postscript typeface, but it doesn't...
    3. flush right type
      With Illustrator CS in XP, a block of flush right type is slightly ragged on the right edge. Any ideas why? Thanks
    4. Flush Right Type ISN'T FLUSH !!!
      Something about ai CS is making me feel like it's still in beta ... I'm designing a small CD-ROM package, and I typed a couple of lines of text,...
    5. flush command on AIX 4.3
      Hi I have program flush in /usr/local/bin and i don't know what is it maybe something like sync command ? please advice and thanks JK
  3. #2

    Default Re: can't flush I know why, but no fix

    Hi tO,

    T. Onoma wrote:
    > I figured out why it won't work. i'm using 1.8's open_uri to retrieve the url with open(url). as soon as this executes everything stops until it downloads the whole file! it isn't a real IO. blah! that stinks. not i wonder if net/http and net/ftp do the same since that's what oprn_uri is based on. if so then means i might have to get down to the socket level just to do a progess reported download. frig'n wonderful!
    >
    > If anyone knows of a better way, or a code snippet i can steal, Please let me know.
    Sorry, I don't know of any code snippets you could use as a starting point.

    However, it might be worthwhile modifying open_uri to allow the asynchronous download and progress notification you want, and then submit a patch, so this can end up in the core code.

    Cheers,

    Harry O.



    Harry Ohlsen Guest

  4. #3

    Default Re: can't flush I know why, but no fix

    On Friday, November 14, 2003, 2:15:18 PM, T. wrote:
    > I figured out why it won't work. i'm using 1.8's open_uri to
    > retrieve the url with open(url). as soon as this executes everything
    > stops until it downloads the whole file! it isn't a real IO. blah!
    > that stinks. not i wonder if net/http and net/ftp do the same since
    > that's what oprn_uri is based on. if so then means i might have to
    > get down to the socket level just to do a progess reported download.
    > frig'n wonderful!
    > If anyone knows of a better way, or a code snippet i can steal, Please let me know.

    net/ftp allows you to download a file a bit at a time. Dunno about
    net/http.

    Gavin


    Gavin Sinclair Guest

  5. #4

    Default Re: can't flush I know why, but no fix

    > However, it might be worthwhile modifying open_uri to allow the asynchronous download and progress notification you want, and then submit a patch, so this can end up in the core code.

    Thanks Harry! I took your advice. Its not quite asynchronous download, but what i did was add in a hook. So now you can do this:

    require 'open_uri'
    progress_proc = proc { |b| print "Downloaded #{b} bytes so far." }
    open(url, progress_proc) { |f| print "Done" }

    This of course will print many lines like:

    Downloaded 1 bytes so far.
    Downloaded 2 bytes so far.
    Downloaded 3 bytes so far.
    Downloaded 4 bytes so far.
    Downloaded 5 bytes so far.
    ...
    Done.

    Not sure the exact count of bytes for each cycle. This really works well with Ruby/ProgressBar though (which moves back to the same line with each pass).

    It probably could be made a tad more robust but I am pretty sure i covered all the base in the code. The this lib's in the distribution of Ruby, so how/who do i give the new version to now?

    -t0

    T. Onoma Guest

  6. #5

    Default Re: can't flush I know why, but no fix

    On Fri, 14 Nov 2003 15:13:58 +0900, T. Onoma wrote:
    >> However, it might be worthwhile modifying open_uri to allow the
    >> asynchronous download and progress notification you want, and then
    >> submit a patch, so this can end up in the core code.
    > Thanks Harry! I took your advice. Its not quite asynchronous download,
    > but what i did was add in a hook. So now you can do this:
    ...
    > It probably could be made a tad more robust but I am pretty sure i
    > covered all the base in the code. The this lib's in the distribution of
    > Ruby, so how/who do i give the new version to now?
    Create a patch file (diff -u, I think) and post it to ruby-core, along with
    why you think it would be good to apply. (Not everyone on -core reads
    -talk.)

    -austin
    --
    austin ziegler * [email]austin@halostatue.ca[/email] * Toronto, ON, Canada
    software designer * pragmatic programmer * 2003.11.14
    * 07.57.22



    Austin Ziegler Guest

  7. #6

    Default Re: can't flush I know why, but no fix

    > Create a patch file (diff -u, I think) and post it to ruby-core, along with
    > why you think it would be good to apply. (Not everyone on -core reads
    > -talk.)
    thanks austin,

    i tried it, but core rejected my post saying i wasn't a member. perhaps i should [ANN] here to get it noticed?

    -t0

    T. Onoma Guest

  8. #7

    Default Re: can't flush I know why, but no fix

    > i tried it, but core rejected my post saying i wasn't a member. perhaps i should [ANN] here to get it noticed?

    hey i became member of core! and i even helped contribute. damn that feels good! :)

    -t0



    T. Onoma Guest

  9. #8

    Default Re: can't flush I know why, but no fix

    On Sat, 15 Nov 2003 04:49:30 +0900, T. Onoma wrote:
    > i tried it, but core rejected my post saying i wasn't a member. perhaps i
    > should [ANN] here to get it noticed?
    Send it directly to me and I'll post it to -core on your behalf.

    -austin
    --
    austin ziegler * [email]austin@halostatue.ca[/email] * Toronto, ON, Canada
    software designer * pragmatic programmer * 2003.11.14
    * 16.57.02



    Austin Ziegler Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139