> But I can't figure out how I would solve the following: > > 1 Alice asks Sam for "foobar.iso" > 2 Sam can't find "foobar.iso" in "cachedir" > 3 Sam requests "foobar.iso" from uplink > 4 Sam saves and forwards to Alice > 5 At about 30 % of the download Bob asks Sam for "foobar.iso" > 6 How do I serve Bob now?
Let every file in your download cache be represented by a Python object. Instead of streaming the file directly to the clients, you can stream the objects. The object will know if the file it represents has finished downloading or not, where the file is located etc. This way you can also, for the sake of persistence, keep partially downloaded files separate from the completely downloaded files, as per a previous suggestion, so that you won't start serving half files after a crash, and it'll be completely transparent in all code except for your proxy file objects. Martin -- http://mail.python.org/mailman/listinfo/python-list