Ask a Question related to Ruby, Design and Development.
-
T. Onoma #1
retry does not work
matz:
you rejected my rcr on garden saying that retry already does it. but it does not. maybe there's a trick to it? but i could not read your example b/c it was cut off by the < --you have to use < [Aside: why hasn't this been fixed at garden? argghhh..]
so please show me how resume would work with retry here. here is the example again:
def resume_example(x)
begin
print x
x = x + 4
if x < 10
raise
end
print x
rescue
x = 10
resume # if retry -> 51014
end
puts
end
resume_example(5) # -> 510
thanks matz,
-t0
T. Onoma Guest
-
PDF request service (second retry)
greetings and salutations, o smarter than i. i've been working on a solution to secure the delivery of pdfs to client browsers. we're introducing... -
PDF request service (retry post)
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????... -
CFMX7 PROBLEM!!! Auto retry upon request timeout
Just upgraded to CFMX7 from CF5. Basically everything is running smoothly expect one serious problem. We have a process which takes more than 3... -
A code snippet: Controlled retry
I sometimes find myself retrying operations when in a networked situation (e.g., maybe server isn't up, just try again). I just wrote this little... -
ssl bad write retry
I've got a Ruby script that uploads a file to another Ruby cgi script. It works fine on a non-ssl site, but when I use the SSL site with net/https,... -
ts #2
Re: retry does not work
>>>>> "T" == T Onoma <transami@runbox.com> writes:
T> you rejected my rcr on garden saying that retry already does it. but it
T> does not. maybe there's a trick to it? but i could not read your example
T> b/c it was cut off by the < --you have to use < [Aside: why hasn't
T> this been fixed at garden? argghhh..]
Well the example was probably
def resume_example(x)
print x
x += 4
begin
raise if x < 10
print x
rescue
x = 10
retry
end
puts
end
Guy Decoux
ts Guest
-
T. Onoma #3
Re: retry does not work
Guy Decoux:
you have refactored my code to achieve the result. is all code so easily refactored?> Well the example was probably
>
> def resume_example(x)
> print x
> x += 4
> begin
> raise if x < 10
> print x
> rescue
> x = 10
> retry
> end
> puts
> end
def i_am_libaray_code
# this is a library call
# to be used in many differnt apps
# do not add user interface code!
raise SpecialWaring, "Warning, incoming!"
...
end
def resume_example(x)
begin
i_am_library_code
rescue SpecialWaring => e
puts e
resume
end
end
i can not refactor the lib call to conatin stdout, and i need a message from it about its status. perhaps there is another way to do this. if you know please tell!
-t0
T. Onoma Guest
-
Yukihiro Matsumoto #4
Re: retry does not work
Hi,
In message "retry does not work"
on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
|you rejected my rcr on garden saying that retry already does it. but it does not. maybe there's a trick to it? but i could not read your example b/c it was cut off by the < --you have to use < [Aside: why hasn't this been fixed at garden? argghhh..]
|
|so please show me how resume would work with retry here. here is the example again:
Check the code carefully (note where "begin" is). It's not just
replacing resume with retry. "retry" jumps back to "begin".
|def resume_example(x)
| begin
| print x
| x = x + 4
| if x < 10
| raise
| end
| print x
| rescue
| x = 10
| resume # if retry -> 51014
| end
| puts
|end
|resume_example(5) # -> 510
def resume_example(x)
print x
x = x + 4
begin
if x < 10
raise
end
print x
rescue
x = 10
retry
end
puts
end
resume_example(5) # -> 510
matz.
Yukihiro Matsumoto Guest
-
ts #5
Re: retry does not work
>>>>> "T" == T Onoma <transami@runbox.com> writes:
T> i can not refactor the lib call to conatin stdout, and i need a message
T> from it about its status. perhaps there is another way to do this. if
T> you know please tell!
Becuase you can't refactor the library, you *can't* use resume like you
want use it because you know nothing about the internal of this library
Guy Decoux
ts Guest
-
Robert Klemme #6
Re: retry does not work
"T. Onoma" <transami@runbox.com> schrieb im Newsbeitrag
news:E1AMm57-0002fp-HX@odie.runbox.com...refactored?> Guy Decoux:
>>> > Well the example was probably
> >
> > def resume_example(x)
> > print x
> > x += 4
> > begin
> > raise if x < 10
> > print x
> > rescue
> > x = 10
> > retry
> > end
> > puts
> > end
> you have refactored my code to achieve the result. is all code so easilyfrom it about its status. perhaps there is another way to do this. if you>
> def i_am_libaray_code
> # this is a library call
> # to be used in many differnt apps
> # do not add user interface code!
> raise SpecialWaring, "Warning, incoming!"
> ...
> end
>
> def resume_example(x)
> begin
> i_am_library_code
> rescue SpecialWaring => e
> puts e
> resume
> end
> end
>
> i can not refactor the lib call to conatin stdout, and i need a message
know please tell!
What strikes me is that you use "resume" in the rescue clause instead of
"retry". Is that on purpose or is maybe a simple misspelling the reason
for your frustration.
Kind regards
robert
Robert Klemme Guest
-
T. Onoma #7
Re: retry does not work
Guy:
no, i wrote the library. ;) but i don't want interface code in it so i can resue it under differnt circumstances.> Becuase you can't refactor the library, you *can't* use resume like you
> want use it because you know nothing about the internal of this library
-t0
T. Onoma Guest
-
ts #8
Re: retry does not work
>>>>> "T" == T Onoma <transami@runbox.com> writes:
T> no, i wrote the library. ;) but i don't want interface code in it so i
T> can resue it under differnt circumstances.
Then change it : your need of resume in this case, just means that your
library was badly designed
Guy Decoux
ts Guest
-
Yukihiro Matsumoto #9
Re: retry does not work
Hi,
In message "Re: retry does not work"
on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
|you have refactored my code to achieve the result. is all code so easily refactored?
Not all, but most.
Your "resume" makes exception handling much harder. With "resume",
every raise can be re-entered, that means programmers need to care
about re-entrance always.
So allowing new thing is not always a good thing.
matz.
Yukihiro Matsumoto Guest
-
T. Onoma #10
Re: retry does not work
Hi matz,
thanks for reposting, someone should really fix that bug on ruby garden.
so Guy gave me same answer. i have problem with it. could you look at those and let me know? ( you probably already are \:)
-t0
T. Onoma Guest
-
T. Onoma #11
Re: retry does not work
Guy:
thats crap.> T> no, i wrote the library. ;) but i don't want interface code in it so i
> T> can resue it under differnt circumstances.
>
> Then change it : your need of resume in this case, just means that your
> library was badly designed
were taking about seperation of concerns --that's not bad design. i have a library i use for downloading files. i have a user interface script that uses the library. things happen in the library and if the user has set verbose more i should be able to report them to the user *without* having to write special esoteric message passing code.
sounds aweful dosen't it? come on, are you goating me?
-ts
T. Onoma Guest
-
ts #12
Re: retry does not work
>>>>> "T" == T Onoma <transami@runbox.com> writes:
T> were taking about seperation of concerns --that's not bad design. i have
T> a library i use for downloading files. i have a user interface script
T> that uses the library. things happen in the library and if the user has
T> set verbose more i should be able to report them to the user *without*
T> having to write special esoteric message passing code.
You are raising an exception, this is, for me, different than sending
message to stdout
Guy Decoux
ts Guest
-
T. Onoma #13
Re: retry does not work
matz:
worry? isn't that what testers are for ;)> Your "resume" makes exception handling much harder. With "resume",
> every raise can be re-entered, that means programmers need to care
> about re-entrance always.
>
> So allowing new thing is not always a good thing.
okay, so maybe there could be an option put on raise to allow resuming?
just as an example of what this could do: tanaka is adding hook into open_uri to do progress reporting of download. to make it work you have to pass a lambda that acts on progress. but with resume you could raise a ProgressException(pos) and resume, which is much cleaner.
-t0
T. Onoma Guest
-
T. Onoma #14
Re: retry does not work
> You are raising an exception, this is, for me, different than sending
okay, i grant you that was not the intention of raise when designed. but a rose by any other name....> message to stdout
so what other means are there? should a raise_message be added? or maybe you are right. maybe my library is "badly designed", but if so then tell me what would the alternative be that achieves such seperation?
-t0
T. Onoma Guest
-
Yukihiro Matsumoto #15
Re: retry does not work
Hi,
In message "Re: retry does not work"
on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
| so Guy gave me same answer. i have problem with it. could you look at those and let me know? ( you probably already are \:)
I'm sorry; which is your problem? [ruby-talk:85791]?
In message [ruby-talk:85791], you wrote:
|were taking about seperation of concerns --that's not bad design. i
|have a library i use for downloading files. i have a user interface
|script that uses the library. things happen in the library and if the
|user has set verbose more i should be able to report them to the user
|*without* having to write special esoteric message passing code.
"resume" won't work well unless both your code and the user code know
each other (the user code must care that raise might resume; your code
must know how to fix up the exception cause). In that case, I think
you can make "retry" work, otherwise you can't make them work well
anyway.
matz.
Yukihiro Matsumoto Guest
-
Yukihiro Matsumoto #16
Re: retry does not work
Hi,
In message "Re: retry does not work"
on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
|just as an example of what this could do: tanaka is adding hook into open_uri to do progress reporting of download. to make it work you have to pass a lambda that acts on progress. but with resume you could raise a ProgressException(pos) and resume, which is much cleaner.
Sounds like exception abuse for me. You can use continuation if you
want to do something like that.
matz.
Yukihiro Matsumoto Guest
-
ts #17
Re: retry does not work
>>>>> "T" == T Onoma <transami@runbox.com> writes:
T> so what other means are there? should a raise_message be added? or maybe
T> you are right. maybe my library is "badly designed", but if so then tell
T> me what would the alternative be that achieves such seperation?
svg% cat b.rb
#!./ruby
def send_message
warn "message"
end
$-w = nil
puts "before"
send_message
puts "after"
class A
def write(string)
puts "a nice message #{string}"
end
end
$stderr = A.new
$-w = true
send_message
svg%
svg% ruby b.rb
before
after
a nice message message
a nice message
svg%
Guy Decoux
ts Guest
-
T. Onoma #18
Re: retry does not work
that is a good point, but the alternative seems to be passing proc or passing self. self seems like over kill, but passing proc is messy. no win situation here? perhaps this suggests another facility like raise but that does not halt execution. rather it moves up the call chain looking for a handler, if it finds one it executes, if not forget it, and then resumes execution. better RCR?> "resume" won't work well unless both your code and the user code know
> each other (the user code must care that raise might resume; your code
> must know how to fix up the exception cause). In that case, I think
> you can make "retry" work, otherwise you can't make them work well
> anyway.
thanks,
-t0
T. Onoma Guest
-
Yukihiro Matsumoto #19
Re: retry does not work
Hi,
In message "Re: retry does not work"
on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
|that is a good point, but the alternative seems to be passing proc or passing self. self seems like over kill, but passing proc is messy. no win situation here? perhaps this suggests another facility like raise but that does not halt execution. rather it moves up the call chain looking for a handler, if it finds one it executes, if not forget it, and then resumes execution. better RCR?
It's called "coroutine". If you are going to write new RCR, I
recommend you to google it first.
matz.
Yukihiro Matsumoto Guest
-
Robert Klemme #20
Re: retry does not work
"Yukihiro Matsumoto" <matz@ruby-lang.org> schrieb im Newsbeitrag
news:1069327343.081885.18914.nullmailer@picachu.ne tlab.jp...open_uri to do progress reporting of download. to make it work you have to> Hi,
>
> In message "Re: retry does not work"
> on 03/11/20, "T. Onoma" <transami@runbox.com> writes:
>
> |just as an example of what this could do: tanaka is adding hook into
pass a lambda that acts on progress. but with resume you could raise a
ProgressException(pos) and resume, which is much cleaner.Definitely! That's not an exceptional condition, but rather a case for>
> Sounds like exception abuse for me.
regular invocation of a callback.
Isn't that a bit overkill? Hm...> You can use continuation if you
> want to do something like that.
robert
Robert Klemme Guest



Reply With Quote

