python - Reading file to stdout with twisted -


how read file (non-blocking) , print standard output (still non-blocking)? esiest way can think of leaves feeling there must better way. exposing linereceiver - line line modification - functionality more preferred.

from twisted.internet import stdio, protocol twisted.protocols.basic import filesender twisted.internet import reactor  class filereader(protocol.protocol):     def connectionmade(self):         fl = open('myflie.txt', 'rb')         d = filesender().beginfiletransfer(fl, self.transport)         d.addboth(fl.close)         d.addboth(lambda _: reactor.stop())  stdio.standardio(filereader()) reactor.run() 

this weakness of twisted. asynchronous file i/o hard @ all, , may impossible "right". there ticket has been open long time: https://twistedmatrix.com/trac/ticket/3983 may find useful place continue discussion.

the idiom you're using there closest correct offer.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -