RPCFailedError in Google dev_appserver Application

I’m currently part of a team migrating a Python 2.7 app engine application to Python 3.9, and I am having a great deal of difficulty with implementing the legacy memcache bundled service. I’m hoping someone with experience with this might be able to help please.
Whenever our application attempts to call any of the memcache methods, we are constantly getting the same exception – “RPCFailedError: Attempted RPC call without active security ticket”. We have researched this error widely across the web, and have tried everything under the sun to try to correct this, but to no avail.

Our application uses the Bottle framework, and our app is is initialised using the following code:

app = bottle.default_app()
app.config.update({'catchall': False})
app = google.appengine.api.wrap_wsgi_app(app, use_legacy_context_mode=True, use_deferred=False)

I have found that the RPCFailedError is raised within the _MakeCallImpl function within the default_api_stub.py file of the Python AppEngine Runtime code, but there are couple of things we still don’t understand:

  1. Is the DefaultApiStub.ShouldUseRequestSecurityTicketForThread() function meant to be true by some underlying mechanism, or are we supposed to manually turn this on through the DefaultApiStub.SetUseRequestSecurityTicketForThread(True) function call?
  2. If it is true, and the code block in which a ticket is instantiated is executed – by either getting the necessary data from an environment variable (HTTP_X_APPENGINE_API_TICKET) or from the NDB context’s GAE headers – are these also sources that are meant to be set by some underlying mechanism, or are developers supposed to manage that.

Because our application uses NDB extensively, it was decided to create a global context by wrapping the entire request cycle as suggested in this Stack overflow post. In our case we did this through the call dunder method of the Bottle class.

def __call__(self, environ, start_response):
    """ Each instance of :class:'Bottle' is a WSGI application. """
    with self.ndb_client.context():
        return self.wsgi(environ, start_response)

I hope this summarizes our situation and findings most accurately, and any clues would be greatly appreciated. In fact, if you really do help me out, and we get our application running, then I will mail you a copy of a board game for free – wherever you are on the planet!

To fix this issue we have tried to ensure that all code is running on the same thread, but we are not 100% sure that the GAE cloud environment is doing something different to our local development environments (which don’t work either btw).

I’ve also tried to replace memcache altogether but that just has its own set of issues and errors, and since we are also getting the same RPCFailedError for the “deferred” legacy service, we decided to stick with memcache for now.

We’ve also tried this Chromium patch, as detailed here, but it made no difference.

A whole bunch of other changes indicated by the meagre set of similar posts about this problem that we could find on the web, but nothing has worked, or doesn’t really address our particular problem.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật