[Twisted-Python] Sending large files over network with perspective broker

Gabriele Lanaro gabriele.lanaro at gmail.com
Sat May 22 14:35:16 EDT 2010


I'm writing a gtk application that transfer files in LAN. The application
has a server and can spawn different clients (one for each file to send) .
The flow between client and server is something like that:

client asks pb.Root a FileSender ( that is conceptually a perspective).
The client receive the file sender.
The client declares the size and the basename of the file he is sending,
requiring authorization to send.
The server perform authorization and passes to the client a unique key to
start the file transfer.
The client performs the file transfer in "chunks". Each chunk is passed
throught a remote method, send_chunk.

The file transfer is done "recursively", each send_chunk deferred generates
a new deferred for the next chunk.

Some pseudocode to understand better my solution.

FileSender:
    remote_get_auth():
    remote_request_for_sending(filename, size): return secret
    remote send_chunk(secred, chunk_no, data): save the chunk somewhere

Client()
    proceed_sending():

          chunk_tot = CHUNK_TOT
          chunk_no = 0

          def send(_)
                if chunk_no == CHUNK_TOT: return
                else:
                     ... read data...
                    d = filesender.callRemote("send_chunk", secret,
chunk_no, data)
                    d.addCallback(send)

I've done in this way so a new chunk is sent only if the previous chunk was
sent.
The problem of this approach is that this blocks my GUI, I can't figure out
why because I'm just generating deffereds so it souldn't block.

I've seen the page about Consumer and Producer, however I can't figure out
how to integrate producer and consumers in a Perspective Broker based code.

Can someone help me?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100522/0650ce3c/attachment.htm 


More information about the Twisted-Python mailing list