python-ping
python-ping copied to clipboard
The current experimental generator functionality breaks myStats.
Description
The iteration of the master branchat db9553f98b40d69950a40547f9454934e3f18ec7 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 db9553f98b40d69950a40547f9454934e3f18ec7 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
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 ! :)
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.
https://github.com/l4m3rx/python-ping/commit/db9553f98b40d69950a40547f9454934e3f18ec7 merged into master.
https://github.com/l4m3rx/python-ping/commit/a0f488c7564aa83c5e0fe2646d0f43db14acb793
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.....
https://github.com/l4m3rx/python-ping/commit/efc7fb963f1e891ac5f7d762bf1ed48273dae300 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)