On Aug 15, 2005, at 8:38 PM, Chuck Hill wrote:
On Aug 11, 2005, at 3:37 AM, Fabrice Pipart wrote:
Hi List !
I am still stuck in developing a large file upload framework (I will publish it asa it is released!).
Here is my question :
Is there a way to choose the WorkerThread you use?
No, and there should not be. They are all the functionally the same.
or to notify that you want to check that the current one is not actually used by another request?
I think you are misinterpreting what you are seeing. Worker threads are not reused until they fully complete processing a request.
Hummmmm... Strange.
When I use Eclipse in Debug mode, I can see a "pool" of threads ready to handle requests. In my case I have 16 of those.
As I explained previously I have two jobs running at the same time when I start an upload :
- one that actually does the upload (the response to the request is only sent when the upload is finished : it is necessary to keep the InputStream opened)
- one that reloads the page that monitors the progress of the upload (communication between the two processes is done through the Session since I did not find any better way). That request-response loop is "short" since it only has to update the progress value.
When I use Firefox as the client browser (the behavior is slightly different with Safari though I cannot explain why), here is what happens if I do 1 upload :
- the upload uses one WorkerThread
- the page reloading request-response uses another
- you can still navigate in the app (it uses either a third thread or the same as the page reloading which does not "block" as the upload does)
Here is what happens if I upload 2 files at the same time
- Upload 1 blocks a WorkerThread during the upload
- Upload 2 blocks another one
- the page reloading of the two upload tries to execute in the same thread as the second upload. I can see this easily since as soon as the second upload is finished, the page reloading is "unblocked" and occurs 4 times in that thread (this has been verified by putting breakpoints)
Here is what happens if I do several uploads
- the 3rd or 4th upload is blocked because it tries to do the upload in a WorkerThread that is already used by the 1st or 2nd upload...
- the page reloading is also blocked
So, did I miss something to notify clearly that I am using the WorkerThread for the upload and that no other request should be sent to that WorkerThread?
Is there a way to put a page reloading in a seperate thread?
I'm not sure what you mean here.
I mean I would like to use a seperate thread to handle the upload request, not a WorkerThread.
Quick description of why I ask such a question:
when you want to upload a file in my application, two portions of code begin to run concurrently :
- one to manage the upload itself
- an other to refresh the progress bar
I tried that one and I based a part of my code on his. But it is totally new and simpler code. His solution blocked the user, he could not navigate in the app while uploading and therefore could not do several uploads at the same time. I was not satisfied with this.
But currently I have a nasty problem : the refreshing of the progress page uses the same WorkerThread as the upload... though many other thread are "free"
Not seeing the code, I'm not sure what you are seeing here. They should not be using the same worker thread. If both are referring to the session then WO will block on the second request to check out the session. If both are referring to the same editing context, your code will also block there.
In fact, my code is not yet used when it blocks. It seems that the request is sent to the used WorkerThread and executed as soon as it is freed. So I guess I am not puting any lock on the session or the editing context since it is not executing "my" code.
The page reloading is simply a WOLongResponse page with nothing else but Thread.sleep() in its performAction and a lastStatus method that gets the progress from the user session. The performAction is executed in a seperate thread (not a WorkerThread) and if I put a breakpoint at the first line of lastStatus, it is only hit when the WorkerThread is freed.
Do you want me to post the code somewhere?
And also when you want to upload several files at the same time, again, a thread already used by another upload tries to be accessed and therefore the last upload has to wait for the first one to finish.
But if you try to navigate in the application during the upload, it works fine and it "seems" that the WorkerThread of the upload is never attempted to be used.
So, why does the reload of the progress bar tries to use the same WorkerThread ?
Does that get you any closer to understanding what is going wrong?
Unfortunately, not really :(
The only difference I see is the way the request is initiated.
Here is the workflow (everything has a reason to be like this) :
- the user is in the main page
- he clicks a button to start an upload -> a popup is opened with two frames : one with the upload form (choose file...) and one dedicated to the progress bar
- when he submits the upload form, that frame is blocked by the upload (normal submit) and the progress bar reloading starts (_javascript_ to do this in the other frame)
- he can still navigate in the main page
Does that give you an idea of anything I do wrong?
Thanks a lot !
Fabrice
Chuck
--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development problems.