I'm using cloud task for async processing of App Engine requests:
<app-engine-instance>/request -> <task_queue>/longrunning_task
I realised that I'm duplicating a lot of code like database models.
A easier solution would be if I could instead make request to itself
<app-engine-instance>/request -> <app-engine-instance>/longrunning_task
How is this possible?
Although duplicating code might sound like a mistake, this is the intended way of performing the operations combining AppEngine and Cloud Tasks, especially for longer tasks.
Requests for AppEngine are limited to 60 seconds, while Cloud Tasks do not fall under such limitations. So, as already pointed out by guillaume blaquiere, if your long running task takes less than 60 seconds, you can perform a call from your code. Else, you have to use Cloud Task to handle long running tasks which is documented here.
For long-running jobs, we recommend usingCloud Tasks. With Cloud Tasks, HTTP requests are long-lived and return a response only after any asynchronous work ends.
Having said that, it is possible for an AppEngine instance to send a request to itself. But it is worth to note that AppEngine's requests are probably not going to the same instance originating the request, the only occasion where this will happen is when there is only one instance and usually this is not a best practice.