ASINetworkQueue setQueueDidFinishSelector 选择器提前结束?

发布于 2024-11-29 23:48:50 字数 2768 浏览 2 评论 0原文

我刚刚开始测试我构建的一些上传实用程序,并放置了 47 个项目进行上传,但队列在第 15、18 或 21 个项目处随机停止,不确定到底为什么,但选择器被调用得太早,而并非全部请求已结束。

我做的唯一特别的事情是将最大并发请求数提高到 6 而不是 4 ,但是 这似乎不是一个大问题。

我按如下方式配置我的选择器:

[self.uploadQueue setDelegate: self];
[self.uploadQueue cancelAllOperations];
[self.uploadQueue setRequestDidStartSelector: @selector(uploadRequestStarted:)];
[self.uploadQueue setRequestDidFinishSelector:@selector(uploadRequestEnded:)];
[self.uploadQueue setQueueDidFinishSelector:@selector(uploadQueueEnded:)];
[self.uploadQueue setDownloadProgressDelegate: myProgress];
[self.uploadQueue showAccurateProgress];

这是我的日志:

2011-08-18 12:39:03.916 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView startUpload] Num requests: 47
2011-08-18 12:39:08.987 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #3 successfully!
2011-08-18 12:39:09.036 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #2 successfully!
2011-08-18 12:39:09.911 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #0 successfully!
2011-08-18 12:39:09.913 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #5 successfully!
2011-08-18 12:39:10.011 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #4 successfully!
2011-08-18 12:39:12.691 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #6 successfully!
2011-08-18 12:39:13.588 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #9 successfully!
2011-08-18 12:39:14.205 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #8 successfully!
2011-08-18 12:39:14.229 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #10 successfully!
2011-08-18 12:39:15.739 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #11 successfully!
2011-08-18 12:39:17.278 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #12 successfully!
2011-08-18 12:39:17.894 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #13 successfully!
2011-08-18 12:39:18.815 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #15 successfully!
2011-08-18 12:39:18.986 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #14 successfully!
2011-08-18 12:39:19.191 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadQueueEnded:] queue ended?

很想听听你们的任何建议:) 提前致谢, 谢伊。

I've just started testing some upload utility i've built and put 47 items for upload, but the queue stops randomly at the 15th or 18th or 21st item, not sure exactly why, but the selector is being called too early while not all the requests are over.

Only thing i did which is special is raise the maxconcurrent requests to 6 instead of 4 , but
that doesn't seem like a huge issue.

I'm configuring my selectors as follows:

[self.uploadQueue setDelegate: self];
[self.uploadQueue cancelAllOperations];
[self.uploadQueue setRequestDidStartSelector: @selector(uploadRequestStarted:)];
[self.uploadQueue setRequestDidFinishSelector:@selector(uploadRequestEnded:)];
[self.uploadQueue setQueueDidFinishSelector:@selector(uploadQueueEnded:)];
[self.uploadQueue setDownloadProgressDelegate: myProgress];
[self.uploadQueue showAccurateProgress];

Here is my log:

2011-08-18 12:39:03.916 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView startUpload] Num requests: 47
2011-08-18 12:39:08.987 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #3 successfully!
2011-08-18 12:39:09.036 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #2 successfully!
2011-08-18 12:39:09.911 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #0 successfully!
2011-08-18 12:39:09.913 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #5 successfully!
2011-08-18 12:39:10.011 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #4 successfully!
2011-08-18 12:39:12.691 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #6 successfully!
2011-08-18 12:39:13.588 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #9 successfully!
2011-08-18 12:39:14.205 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #8 successfully!
2011-08-18 12:39:14.229 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #10 successfully!
2011-08-18 12:39:15.739 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #11 successfully!
2011-08-18 12:39:17.278 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #12 successfully!
2011-08-18 12:39:17.894 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #13 successfully!
2011-08-18 12:39:18.815 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #15 successfully!
2011-08-18 12:39:18.986 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadRequestEnded:] Finished uploading photo #14 successfully!
2011-08-18 12:39:19.191 MyTestApp[4240/0xacc992c0] [lvl=2] -[MyView uploadQueueEnded:] queue ended?

Would love to hear any of you suggestions :)
Thanks in advance,
Shai.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风追烟花雨 2024-12-06 23:48:50

您是否尝试将 setShouldCancelAllRequestsOnFailure: 设置为 NO ?队列的默认行为是在任何单个请求失败时取消所有剩余请求。

请求可能失败(由于某种原因),导致您的队列过早完成。

Have you tried setting setShouldCancelAllRequestsOnFailure: to NO ? The default behaviour of a queue is for it to cancel all remaining requests if any single request fails.

It may be that a request is failing (for some reason) which is causing you queue to finish prematurely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文