[Twisted-Python] exceptions.AttributeError: 'NoneType' object has no attribute 'write'
Stefano Canepa
sc at linux.it
Tue Oct 18 07:06:25 MDT 2005
Hi all,
I have this error running the simple module I wrote after the error.
$ ./TCAdrvC.py
sending to TCA: MSH|^~\&|XLIS|CLILAB|CLC^1|TCA|20010101080811||OML^O21|
200101010OBR|1|123456^XLIS||0001^Aliquot^XLIS||||||||DC1|||SER|3||
pippo:
MSH|^~\&|XLIS|CLILAB|CLC^1|TCA|20010101080811||OML^O21|20010101080811|
P|2.4|||NOBR|1|123456^XLIS||0001^Aliquot^XLIS||||||||DC1|||SER|3||
None
Peer will receive following PB traceback:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/twisted/spread/banana.py", line
114, in gotItem
self.callExpressionReceived(item)
File "/usr/lib/python2.3/site-packages/twisted/spread/banana.py", line
81, in callExpressionReceived
self.expressionReceived(obj)
File "/usr/lib/python2.3/site-packages/twisted/spread/pb.py", line
561, in expressionReceived
method(*sexp[1:])
File "/usr/lib/python2.3/site-packages/twisted/spread/pb.py", line
872, in proto_message
self._recvMessage(self.localObjectForID, requestID, objectID,
message, answerRequired, netArgs, netKw)
--- <exception caught here> ---
File "/usr/lib/python2.3/site-packages/twisted/spread/pb.py", line
886, in _recvMessage
netResult = object.remoteMessageReceived(self, message, netArgs,
netKw)
File "/usr/lib/python2.3/site-packages/twisted/spread/flavors.py",
line 113, in remoteMessageReceived
state = method(*args, **kw)
File "./TCAdrvC.py", line 102, in remote_sendToTCA
d.addCallback(self.sendMsg(msg,RETRIES))
File "/home/sc/Sviluppo/CCIC/HL7/HL7LLPSpecialClient.py", line 122, in
sendMsg self.sendLine(msgToSend)
File "/usr/lib/python2.3/site-packages/twisted/protocols/basic.py",
line 269, in sendLine
return self.transport.write(line + self.delimiter)
exceptions.AttributeError: 'NoneType' object has no attribute 'write'
class Receiver(pb.Root, HL7LLPClientProtocol):
def __init__(self):
HL7LLPClientProtocol.__init__(self)
def remote_sendToTCA(self, msg):
self.delimiter = "\x02"
## if DEBUG:
print 'sending to TCA:', msg
# Create creator and connect
clientCreator = protocol.ClientCreator(reactor,
HL7LLPClientProtocol)
d = clientCreator.connectTCP(SERVER, PORT)
d.addCallback(self.sendMsg(msg,RETRIES))
return msg
def main():
reactor.listenTCP(LISTENPORT, pb.PBServerFactory(Receiver()))
reactor.run()
---------
the module HL7LLPClientProtocol is:
class HL7LLPClientProtocol(LineReceiver):
delimiter = "\x02"
def sendMsg(self, msg, numRetries=RETRIES):
self.msg = msg
msgToSend = "\x01"+msg +"\x0d"
self.sendLine(msgToSend)
return self.timeoutAndRetry(numRetries)
...
Which is my mistake?
Bye
Stefano
--
Stefano Canepa aka sc: sc at linux.it http://www.stefanocanepa.it
Three great virtues of a programmer: laziness, impatience and hubris.
Le tre grandi virtù di un programmatore: pigrizia, impazienza e
arroganza. (Larry Wall)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: </pipermail/twisted-python/attachments/20051018/d561d1cc/attachment.sig>
More information about the Twisted-Python
mailing list