Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop when viewing console output #8

Closed
Wylan opened this issue Apr 3, 2015 · 8 comments
Closed

Infinite loop when viewing console output #8

Wylan opened this issue Apr 3, 2015 · 8 comments

Comments

@Wylan
Copy link

Wylan commented Apr 3, 2015

After updating the the latest version of the gem we have encountered an issue when trying to parse a document via the console. The console will hang until ctrl+c is pressed. Reverting to the older version seems to resolve the issue.

I believe it is being caused by line 54 in base.rb, commenting out super.inspect seems to resolve the issue, but the output is less legible. The project is using Ruby 2.1.4.

def inspect
   "#{self.class.to_s.sub(/^.*::/, '')} (#{name}) #{repeats} #{super.inspect[1..-2]} =<#{parsed_str}, #{next_repeat.inspect}> ".gsub(/\\*\"/, '"')
end
@mjpete3
Copy link
Owner

mjpete3 commented Apr 13, 2015

Wylan,

Have you been able to come up with a better work around instead of commenting out the line?
I haven't had a chance to really look at the issue yet.
Marty

@Wylan
Copy link
Author

Wylan commented Apr 13, 2015

Hi Marty,

I've been pretty busy so I haven't had a chance to dive deeper into it yet, but hopefully I will this weekend.

@Wylan
Copy link
Author

Wylan commented Apr 14, 2015

So I had a little more time to look into the issue and it seems that changing

#{next_repeat.inspect}

to

#{next_repeat}

avoids the issue, but again the output is not super legible.

@mjpete3
Copy link
Owner

mjpete3 commented Apr 15, 2015

This is very helpful. I'm trying to see if I can free up some time this
weekend to work on the code. In addition to working full time, I'm also
starting up a new business. Time is a premium. The work your putting
in is extremely helpful and appreciated!!

I think this may stem from the newer version of Ruby (although I may be
wrong on that).

Marty

On Tue, 2015-04-14 at 09:25 -0700, Wylan wrote:

So I had a little more time to look into the issue and it seems that
changing

#{next_repeat.inspect}
to

#{next_repeat}
avoids the issue, but again the output is not super legible.


Reply to this email directly or view it on GitHub.

@Wylan
Copy link
Author

Wylan commented Apr 15, 2015

I'm glad to be able to help, we using the gem in a project at work so I am able to take some time during the day to look into it. I too suspect that the ruby version has something to do with it since we didnt have issues before upgrading to 2.1, although I'm not sure exactly what changed.

I do think I may have found a decent workaround though. It seems that it was looping in loop.rb (hows that for a pun?). If I copy the inspect method into loop.rb, but remove the call to super.inspect it seems to work. Also the output is not missing anything so far as I can tell.

# inspect in loop.rb
def inspect
  "#{self.class.to_s.sub(/^.*::/, '')} (#{name}) #{repeats} =<#{parsed_str}, #{next_repeat.inspect}> ".gsub(/\\*\"/, '"')
end 

# inspect in base.rb

def inspect
  "#{self.class.to_s.sub(/^.*::/, '')} (#{name}) #{repeats} #{super.inspect[1..-2]} =<#{parsed_str}, #{next_repeat.inspect}> ".gsub(/\\*\"/, '"')
end

@mjpete3
Copy link
Owner

mjpete3 commented Apr 16, 2015

I had some time this morning to research differences with inspect
between ruby 1.9.3 and 2.0.0. In version 1.9.3, the inspect method
would be overridden with to_s method. In version 2.0.0 this was changed
so to_s wouldn't override inspect and the object would be return instead
of a string. The base class has both inspect and to_s methods.

I think what is happening is from the loop class, the base class inspect
method is called. The super.inspect is returning an object, not a
string. Then inspect is being called on that object.....

Your monkey patch makes sense. I'm going to bring it into code base and
release ver 1.5.1 in a little bit.

Marty

On Wed, 2015-04-15 at 08:49 -0700, Wylan wrote:

I'm glad to be able to help, we using the gem in a project at work so
I am able to take some time during the day to look into it. I too
suspect that the ruby version has something to do with it since we
didnt have issues before upgrading to 2.1, although I'm not sure
exactly what changed.

I do think I may have found a decent workaround though. It seems that
it was looping in loop.rb (hows that for a pun?). If I copy the
inspect method into loop.rb, but remove the call to super.inspect it
seems to work. Also the output is not missing anything so far as I can
tell.

inspect in loop.rb

def inspect
"#{self.class.to_s.sub(/^._::/, '')} (#{name}) #{repeats} =<#{parsed_str}, #{next_repeat.inspect}> ".gsub(/_"/, '"')
end

inspect in base.rb

def inspect
"#{self.class.to_s.sub(/^._::/, '')} (#{name}) #{repeats} #{super.inspect[1..-2]} =<#{parsed_str},
#{next_repeat.inspect}> ".gsub(/_"/, '"')
end

Reply to this email directly or view it on GitHub.

@mjpete3
Copy link
Owner

mjpete3 commented Apr 16, 2015

Version 1.5.1 of pd_x12 is available on rubygems.org

On Wed, 2015-04-15 at 08:49 -0700, Wylan wrote:

I'm glad to be able to help, we using the gem in a project at work so
I am able to take some time during the day to look into it. I too
suspect that the ruby version has something to do with it since we
didnt have issues before upgrading to 2.1, although I'm not sure
exactly what changed.

I do think I may have found a decent workaround though. It seems that
it was looping in loop.rb (hows that for a pun?). If I copy the
inspect method into loop.rb, but remove the call to super.inspect it
seems to work. Also the output is not missing anything so far as I can
tell.

inspect in loop.rb

def inspect
"#{self.class.to_s.sub(/^._::/, '')} (#{name}) #{repeats} =<#{parsed_str}, #{next_repeat.inspect}> ".gsub(/_"/, '"')
end

inspect in base.rb

def inspect
"#{self.class.to_s.sub(/^._::/, '')} (#{name}) #{repeats} #{super.inspect[1..-2]} =<#{parsed_str},
#{next_repeat.inspect}> ".gsub(/_"/, '"')
end

Reply to this email directly or view it on GitHub.

@Wylan
Copy link
Author

Wylan commented Apr 16, 2015

Glad I was able to help, I just updated to 1.5.1 and everything seems to be working as expected.

@Wylan Wylan closed this as completed Apr 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants