2020-06-23 05:25:42+00:00

Running legacy Google App Engine applications locally typically requires launching the full GAE dev server (dev_appserver.py). As developers migrate applications to modern python environments, running the legacy dev server becomes hard to maintain. Developers need to run tests locally using lightweight standard test runners like pytest or serve applications using WSGI servers like Gunicorn. Mocking GAE APIs using stubs is essential to achieve this offline execution model.

By writing fallback classes that intercept NDB and Memcache calls, we can run App Engine applications locally without cloud dependencies.


1. Structuring Mock Memcache Stubs

When running outside the GAE sandbox, native memcache imports fail. We write a fallback wrapper using standard in-memory dictionaries or Redis clients:

# mock_memcache.py
class MockMemcacheClient:
    def __init__(self):
        self._store = {}
        
    def get(self, key):
        return self._store.get(key)
        
    def set(self, key, val, time=0):
        self._store[key] = val
        return True
        
    def delete(self, key):
        self._store.pop(key, None)
        return True

# Application bootloader fallback
try:
    from google.appengine.api import memcache
except ImportError:
    # Load fallback stub
    memcache = MockMemcacheClient()

2. Enabling Fast Local Iterations

By loading these mock stubs automatically when local environment variables are detected, developers can execute python scripts and run test cases instantly without cloud dependencies.

Zero-Copy Shared Memory IPC Between Python Daemons on Embedded Linux

Use multiprocessing.shared_memory and POSIX message queues to exchange high-rate sensor frames between acquisition and cloud-sync processes with minimal CPU overhead.


About the Author — Hire Freelance Programmer Aldian Fazrihady

Aldian Fazrihady is a Top-Rated Senior Freelance Programmer, Freelance Full Stack Developer, and AI Application Engineer with 15+ years of production software engineering experience and Google Cloud Professional Cloud Architect & Data Engineer certifications. He specializes in building custom LLM & autonomous AI agents, RAG pipelines, Next.js/React PWAs, Python (Django/FastAPI), Go microservices, and serverless cloud infrastructure on Google Cloud Run and AWS.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD via Polar) | View Live AI Portfolio | Portfolio Directory | Send a Direct Message

Related Engineering Articles

Freelance Programmer Specializations & Category Hubs