[Twisted-Python] Large Transfers

Uwe C. Schroeder uwe at oss4u.com
Sat May 10 10:45:44 MDT 2003


Ok, I think we all agree that changing Twisted internally to reach a certain 
goal isn't the good choice here. It would be if the benefit was for 
everyone's use.
Asuming I have a pb connection open.
(snippet)
p is the pb.Perspective
parameters is a "small" parameterset (a couple of int's or so)
resultset is [ int, int, string, huge string ]

p.callRemote('getResult',(parameters)).addCallbacks(ok, nok)

def ok(resultset):
	do something with the resultset here  

def nok(error):
	throw error in UI here

If the above is the code, how could I change it using pagers ?
I need the int,int,string result together with the "huge string" result. I 
don't want to use self.int1, self.int2 etc. constructs since it's temporary 
data, so I'd have to give the small results as parameters to the callback 
being called when paging the large part finishes. I'd also need an error 
callback, which I can't find in the pager implementation at all. The "huge 
String" will allways be a string, since the server side will compress 
(possibly encrypt) and base64 encode it anyways.
The current user feedback implementation isn't really one, so maybe I can even 
improve here. Currently it behaves like the netscape or mozilla logo - it 
moves until the data is there. If I can hook into the pager I might be able 
to give real feedback in form of a progress bar or so.

Any ideas ?

On Saturday 10 May 2003 08:36 am, Andrew Bennetts wrote:
> On Sat, May 10, 2003 at 08:20:37AM -0700, Uwe C. Schroeder wrote:
> > You're right, it doesn't. However it still requires several calls to
> > transfer the whole set. :-( And it has another problem. The pager makes
> > it hard to give the user some response while uploading/downloading. The
> > UI gets stuck, or at least appears to be since nothing is happening.
>
> (Untested code)
>
> class ProgressReportingStringPager(StringPager):
>     def __init__(self, ui, *args, **kwargs):
>         self.ui = ui
>         StringPager.__init__(self, *args, **kwargs)
>
>     def nextPage(self):
>         StringPager.nextPage(self)
>         self.ui.reportProgress(self.pointer/len(self.string))
>
> I haven't tried, but it looks like something like that code could easily
> give you progress reporting from your pager.  The paging code is really
> quite simple.
>
> -Andrew.
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

-- 
	UC

--
Open Source Solutions 4U, LLC	2570 Fleetwood Drive
Phone:  +1 650 872 2425		San Bruno, CA 94066
Cell:   +1 650 302 2405		United States
Fax:    +1 650 872 2417





More information about the Twisted-Python mailing list