1

Several times I've seen mention that for asynchronous ping is good to use twisted.

I written implementation on threads (like Ping a site in Python?)

But on ~200 threads i have crush

On page http://twistedmatrix.com/trac/wiki/ProjectsUsingTwisted i find txNetTools - Ping, traceroute, icmp, etc., implemented in Twisted, and a library for those who want to build their own network tools.

Has anyone used this library?

I tried to use it ping.py:

Traceback (most recent call last):
  File "ping.py", line 23, in <module>
    class Pinger(ICMP):
NameError: name 'ICMP' is not defined

if change:

 class Pinger(**ICMP**):

to

class Pinger():

Traceback (most recent call last):
  File "ping.py", line 54, in <module>
    reactor.listenICMP(0, Pinger())
  File "./txnet/reactor.py", line 21, in listenICMP
    p.startListening()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 102, in startListening
    self._connectToProtocol()
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 123, in _connectToProtocol
    self.protocol.makeConnection(self)
AttributeError: Pinger instance has no attribute 'makeConnection'

Maybe I'm doing something wrong or not understand?

P.S. twisted 12.0

Community
  • 1
  • 1
Echeg
  • 2,321
  • 2
  • 21
  • 26

1 Answers1

3

If you are running sandbox/ping.py, then the exception you report doesn't make sense. That file has this import near the beginning:

from txnet.icmp import ICMP, Packet, ECHO_REQUEST

This defines the ICMP name. The Pinger class comes later, extending it. I can successfully run this demo program (though it fails with an unrecognized message type when handling the response on my sytem).

Perhaps you have an old version of the code, or have modified it somehow, or are running a different ping.py?

Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
  • if i run from main/sandbox:ImportError: No module named txnet.icmp . I copy ping.py to 1 level up to main folder – Echeg Feb 23 '12 at 17:47
  • I pulled the latest master and I am still getting this error any ideas? – Kyle Sponable Jul 12 '16 at 01:18
  • I don't really know what's wrong, sorry. However, note the answer is over 4 years old now. Perhaps txnet has introduced further incompatible changes that invalidate this answer. – Jean-Paul Calderone Aug 13 '16 at 11:33