0

Recently our service in appengine was migrated from python2.7 to python3.11, with standard evironement. After migration, we keep seeing errors in threading and the message is not informative enough for debug.

The error seems not within Django framework we are using.

error message

Traceback (most recent call last):
File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 995, in _bootstrap
[2023-08-16 07:12:23 +0000] [18] [INFO] Worker exiting (pid: 18)

and

Traceback (most recent call last):
  File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 995, in _bootstrap
Exception ignored in thread started byException ignored in thread started byException ignored in thread started by: : : Waiting up to 5 seconds.<bound method Thread._bootstrap of <Thread(google.cloud.logging.Worker, started daemon 68606081631808)>><bound method Thread._bootstrap of <Thread(google.cloud.logging.Worker, started daemon 68606081631808)>>

and

Traceback (most recent call last):
  File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 995, in _bootstrap
    self._bootstrap_inner()
  File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 1042, in _bootstrap_inner
    self._delete()
  File "/layers/google.python.runtime/python/lib/python3.11/threading.py", line 1074, in _delete
    del _active[get_ident()]

The app.yaml

runtime: python311
app_engine_apis: true
entrypoint: gunicorn dummy.wsgi:application -b :$PORT -w 8 -t 600

instance_class: F4

handlers:

- url: /internal/.*
  script: auto
  secure: always
  login: optional

- url: /static
  static_dir: static/
  secure: always

- url: /.*
  script: auto
  secure: always

the wsgi.py

from dummy.boot import fix_path
fix_path()

import os
from django.core.wsgi import get_wsgi_application
from djangae.environment import is_production_environment
from google.appengine.api import wrap_wsgi_app

settings = "dummy.settings.live" if is_production_environment() else "dummy.settings.local"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings)

application = get_wsgi_application()
application = wrap_wsgi_app(application)

Does anyone have an idea? Thanks in advance.

YSC
  • 379
  • 1
  • 3
  • 13
  • 2
    Can you share your `app.yaml` , `main.py` ,document you followed to migrate and minimal information to recreate the issue? ***Note: don't share errors as screenshot*** – Roopa M Aug 15 '23 at 05:22
  • I have same issue. No Django - using Flask. Python standard. – dugloon Aug 15 '23 at 21:16
  • @RoopaM app.yaml, main.py, and error messages were updated to the post. The error seems to happen randomly. We haven't found a stable way to recreate the issue. – YSC Aug 17 '23 at 03:28
  • Similar issue? https://stackoverflow.com/questions/8774958/keyerror-in-module-threading-after-a-successful-py-test-run – dugloon Aug 17 '23 at 14:12
  • @dugloon I just found the problem. Please see the answer below. – YSC Aug 22 '23 at 03:13

1 Answers1

0

The django version we used only supports to python 3.10, and we were running on 3.11. After downgrade to python 3.10 and the error disappears.

YSC
  • 379
  • 1
  • 3
  • 13
  • Awesome! Glad you figured it out. I'm running Flask but hopefully I'll have similar luck. I had posted my setup (on this question instead of starting a new question) hoping that it would help - but it was removed probably because it wasn't an answer. – dugloon Aug 22 '23 at 22:56
  • My issue turned out to be the usage of the google api wsgi wrapper - https://github.com/GoogleCloudPlatform/appengine-python-standard. Stopped using it and issue resolved. – dugloon Aug 24 '23 at 19:15