{"action":"created","issue":{"url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/1187","repository_url":"https://api.github.com/repos/google/google-api-dotnet-client","labels_url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/1187/labels{/name}","comments_url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/1187/comments","events_url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/1187/events","html_url":"https://github.com/google/google-api-dotnet-client/issues/1187","id":314162139,"number":1187,"title":"\"Too many open files\" when trying to send many parallel requests","user":{"login":"marcosvcp","id":5839364,"avatar_url":"https://avatars3.githubusercontent.com/u/5839364?v=4","gravatar_id":"","url":"https://api.github.com/users/marcosvcp","html_url":"https://github.com/marcosvcp","followers_url":"https://api.github.com/users/marcosvcp/followers","following_url":"https://api.github.com/users/marcosvcp/following{/other_user}","gists_url":"https://api.github.com/users/marcosvcp/gists{/gist_id}","starred_url":"https://api.github.com/users/marcosvcp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcosvcp/subscriptions","organizations_url":"https://api.github.com/users/marcosvcp/orgs","repos_url":"https://api.github.com/users/marcosvcp/repos","events_url":"https://api.github.com/users/marcosvcp/events{/privacy}","received_events_url":"https://api.github.com/users/marcosvcp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-13T15:55:58Z","updated_at":"2018-04-17T12:45:02Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI'm getting \"Too many open files\" trying to execute InventoryCustomBatch in a parallel requests (max 400).\r\n\r\nThe stacktrace ->\r\n\r\n ```\r\n  at Google.Apis.Http.ConfigurableMessageHandler.<SendAsync>d__43.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Net.Http.HttpClient.<FinishSendAsync>d__58.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Google.Apis.Requests.ClientServiceRequest`1.<ExecuteUnparsedAsync>d__26.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Google.Apis.Requests.ClientServiceRequest`1.<ExecuteAsync>d__23.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n```\r\n\r\nI'm running my code in a AWS-Lambda which means that is a UNIX-Like OS, and UNIX ~open a file~ for every request, so we need to dispose httpmessage to close the ~file~.\r\n\r\nI'm not sure about that, but I think that this code\r\n\r\nhttps://github.com/google/google-api-dotnet-client/blob/master/Src/Support/Google.Apis.Core/Http/ConfigurableMessageHandler.cs#L395\r\n\r\nDoes not dispose the message if cancellationRequested\r\n\r\nCan you guys help me?"},"comment":{"url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/comments/381978985","html_url":"https://github.com/google/google-api-dotnet-client/issues/1187#issuecomment-381978985","issue_url":"https://api.github.com/repos/google/google-api-dotnet-client/issues/1187","id":381978985,"user":{"login":"chrisdunelm","id":316748,"avatar_url":"https://avatars1.githubusercontent.com/u/316748?v=4","gravatar_id":"","url":"https://api.github.com/users/chrisdunelm","html_url":"https://github.com/chrisdunelm","followers_url":"https://api.github.com/users/chrisdunelm/followers","following_url":"https://api.github.com/users/chrisdunelm/following{/other_user}","gists_url":"https://api.github.com/users/chrisdunelm/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdunelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdunelm/subscriptions","organizations_url":"https://api.github.com/users/chrisdunelm/orgs","repos_url":"https://api.github.com/users/chrisdunelm/repos","events_url":"https://api.github.com/users/chrisdunelm/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdunelm/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T12:45:01Z","updated_at":"2018-04-17T12:45:01Z","author_association":"MEMBER","body":"OK, yes, I see that the response message may end up not being disposed of when cancelled.\r\nThere are two places this can happen. The line you pointed out before, and also [ConfigurableMessageHandler.cs line 535](https://github.com/google/google-api-dotnet-client/blob/master/Src/Support/Google.Apis.Core/Http/ConfigurableMessageHandler.cs#L535).\r\nI'll create a PR to fix both."}}
{"actor":{"display_login":"chrisdunelm"}}