0

Given below is the code for a server:

from twisted.internet import protocol
from twisted.internet import reactor

class Echo(protocol.Protocol):

    def dataRecvd(self, data):
        self.transport.write(data)

class EchoFactory(protocol.Factory):

    def buildProtocol(self, addr):
        return Echo()

reactor.listenTCP(8000,EchoFactory())
reactor.run()

I get the following error:

listenTCP()- Undefined variable from import

run- Undefined variable from import

I am using pydev with eclipse on windows 7. Where am I going wrong?

praxmon
  • 5,009
  • 22
  • 74
  • 121
  • `s/dataRecvd/dataReceived/`. Just copy-paste the server example from [Twisted home page](https://twistedmatrix.com/trac/). It works as is. – jfs Feb 19 '14 at 07:26

2 Answers2

1

enter image description heretry rhis add #@UndefinedVariable like:

reactor.listenTCP(8000,EchoFactory())  #@UndefinedVariable
reactor.run() #@UndefinedVariable
Avinash Garg
  • 1,374
  • 14
  • 18
  • No, still no output. What are they supposed to do anyway? And the error went away but the execution does not give any output – praxmon Feb 19 '14 at 07:14
  • @Prakhar Mohan Srivastava:can you try the same code on python shell – Avinash Garg Feb 19 '14 at 07:19
  • @Prakhar Mohan Srivastava Just try to explore twisted.internet you will not find the reactor object When Eclipse/PyDev tries to compile the bytecodedoesn't see the reactor object in the twisted but it will present at runtime – Avinash Garg Feb 19 '14 at 07:24
  • I tried it on the shell too, the program starts executing then nothing. There is no output. – praxmon Feb 19 '14 at 07:33
1

listenTCP()- Undefined variable from import

This isn't a Python exception. I guess it's an "error" from a tool like pylint. It's spurious. It means nothing.

I tried it on the shell too, the program starts executing then nothing. There is no output.

Do you know what the program is supposed to do? It isn't supposed to produce any output in the shell.

Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122