Use ndb.tasklet on Google App Engine

If you paste it in the Interactive Console, it will work as it is. In this case, since the time-consuming do_some is operated in parallel, the processing time is shorter than when it is executed in series.

from time import sleep
from google.appengine.ext import ndb


@ndb.tasklet
def do_some(time):
  yield ndb.sleep(time)
  raise ndb.Return(time)

@ndb.tasklet
def foo():
  a, b = yield (do_some(3), do_some(3))
  raise ndb.Return(a + b)

def main():
  f = foo()
  x = f.get_result()
  print x

main() #Execution time is 3 not 6

Recommended Posts

Use ndb.tasklet on Google App Engine
Use external modules on Google App Engine
How to use Django on Google App Engine / Python
Use Django's ImageField on App Engine / Python
Tweet (API 1.1) on Google App Engine for Python
Use music21 on Google Colaboratory
Deploy a Django application on Google App Engine (Python3)
PIL with Python on Windows 8 (for Google App Engine)
Google App Engine development with Docker
Deploy your Go app on Google App Engine with GitHub Actions
Publish the site for free on Google App Engine (personal memorandum)
Building a development environment with Maven on Google App Engine [Java]
Using properties files with Flexible Environment Java 8 on Google App Engine
Use The Metabolic Disassembler on Google Colaboratory
How to use Google Assistant on Windows 10
[Google App Engine] User Objects (Japanese translation)
I can't deploy with google app engine
Deploy a Python app on Google App Engine and integrate it with GitHub
Google App Engine Datastore and Search API integration
Check when the HTML obtained by Requests on Google App Engine is garbled
How to use a library that is not originally included in Google App Engine
Until you run a Flask application on Google App Engine for the time being
Use pyvenv on Windows
Google App Engine / Python development environment construction procedure (late 2014)
Getting Started with Google App Engine for Python & PHP
Use Ansible on Windows
Use QuTiP on Windows
Use pip on Windows
Runtime version of Google App Engine / Python Standard Environment
Hello World with Google App Engine (Java 8) + Spring Boot + Gradle
Hello World with Google App Engine (Java 8) + Servlet API 3.1 + Gradle
Save in Japanese to StringProperty in Google App Engine data store
Hello World with Google App Engine (Java 11) + Spring Boot + Gradle
Looking back on iOS'Healthcare App' 2019
ls -R on Google Drive
Use matplotlib on Ubuntu 12 & Python
Try StyleGAN on Google Colaboratory
Use Github Desktop on Linux
Plotly Dash on Google Colab
Deploy masonite app on Heroku 2020
Use matplot libwidget on mac
Use sshpass on Amazon linux2
Use Python on Windows (PyCharm)
Use NeoPixel on Raspberry Pi
Use Linux on Windows 10 (WSL2)
Pandas 100 knocks on Google Colaboratory
How to use Google Colaboratory
I want to use shortcut translation like DeepL app on Linux
Settings when writing Google App Engine / Python apps in Intellij Idea
PyPI package for super easy use of Cotoha on Google colab
Read, change, and write Excel files on GCP App Engine Storage
[Google App Engine] Flow from development environment construction to application creation