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

The current experimental generator functionality breaks myStats. #17

Open
EclectickMedia opened this issue Nov 3, 2016 · 5 comments
Open

Comments

@EclectickMedia
Copy link
Collaborator

EclectickMedia commented Nov 3, 2016

Description

The iteration of the master branchat db9553f breaks the myStats functionality when the generators are exited via a keyboard interrupt (see the execution snippet).

I haven't looked to far into it, and will move to that next, but the commit at db9553f is likely fine to be pulled to the repository. This would allow for cleaner repository history via the branch and pull idiom.

If this issue is not overly concerning, the afore mentioned commit can be pulled.

Bugged Execution Snippet

$ sudo python3 ping.py -T
Running PYTHON PING test case.

PYTHON PING 127.0.0.1 (127.0.0.1): 64 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.06 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.12 ms
^C
----0.0.0.0 PYTHON PING Statistics----
0 packets transmitted, 0 packets received, 100.0% packet loss


(Terminated with signal 2)

What should be collected

$ sudo python3 ping.py -T
Running PYTHON PING test case.

PYTHON PING 127.0.0.1 (127.0.0.1): 64 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.06 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.12 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.11 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.11 ms

----127.0.0.1 PYTHON PING Statistics----
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip (ms)  min/avg/max = 0/0.1/0


PYTHON PING 8.8.8.8 (8.8.8.8): 64 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=59 time=46.63 ms
^C
----0.0.0.0 PYTHON PING Statistics----
0 packets transmitted, 0 packets received, 100.0% packet loss

This even shows the broken functionality upon KeyboardInterrupt at the end of the snippet

@l4m3rx
Copy link
Owner

l4m3rx commented Nov 3, 2016

It seems this bug wasnt introduced by your code...the master branch has the same issue.
So i'll merge this code and keep the ticket open so we can fix it at a later stage.

p.s. great work btw ! :)

@EclectickMedia
Copy link
Collaborator Author

EclectickMedia commented Nov 3, 2016

What can I say, I'm a bit of a perfectionist.

I believe I know how to fix the issue, but I may just have to play with it for a bit.

@l4m3rx
Copy link
Owner

l4m3rx commented Nov 3, 2016

db9553f merged into master.

a0f488c

@EclectickMedia
Copy link
Collaborator Author

So, I did a bit of poking around and found what our issue is.

No matter what, when _sig_handler gets called, it does not access an instanced object of MyStats (i.e during execution of verbose_ping or quiet_ping even after the module level declaration of myStats has been instanced and modified, _sig_handler doesn't access said instance).

I'm still looking for a solution however.....

@l4m3rx
Copy link
Owner

l4m3rx commented Nov 4, 2016

efc7fb9
Making myStats global (in verbose_ping() and _signal_handler() )
Temporary fix.... but we should find another way to do this.


> l4m3rx@cryptohui:git/python-ping master# python3 ping.py -T
> Running PYTHON PING test case.
> 
> PYTHON PING 127.0.0.1 (127.0.0.1): 64 data bytes
> 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.09 ms
> 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.14 ms
> ^C
> ----127.0.0.1 PYTHON PING Statistics----
> 2 packets transmitted, 2 packets received, 0.0% packet loss
> round-trip (ms)  min/avg/max = 0.1/0.1/0.1
> 
> 
> (Terminated with signal 2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants