<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<div class="moz-text-flowed"
 style="font-family: -moz-fixed; font-size: 13px;" lang="x-western">Hi,
<br>
<br>
I am working on an application where clients request files, and since
each file is very large, the server ACKs the requests and then queues
them to be served later, one at a time.
<br>
I am relatively new to Twisted and was wondering what would be the best
way to approach this.
<br>
<br>
Here is what I came up with so far:
<br>
<br>
1) Use Deferred callbacks, and string together callbacks to a "file
sender" function - once a file is sent, the function is called back
with a pointer to the next file in line.
<br>
If I do so - is there some automatic garbage collection of the
callbacks that have already been handled? (there may eventually be
hundreds of files to be sent)
<br>
In this approach, would there be a natural way to check if a new
request is actually a repeat of a previous request already queued?
<br>
<br>
2) Use some type of queue - where each new file request is queued, and
some single function handles them one at at time (I guess with
asynchronous callbacks to itself every time the transport layer is free
to send another file and the queue is not empty).
<br>
Is there some queue structure like this in Twisted? I saw something
called a DefferedQueue but could not find many examples or
documentation about it and about its usage.
<br>
<br>
I mainly want to understand, from the "Twisted mindset"&nbsp; which would be
the the right way to go?
<br>
Also, say in the future I would want to implement priority queuing and
handling of the requests rather than a FIFO - how would I do that in
Twisted?
<br>
<br>
Any thoughts and/or code examples would be greatly appreciated
<br>
Thanks!
<br>
Nadav
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</body>
</html>