You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/11/09 14:34:40 UTC

[GitHub] [skywalking] jiang1997 commented on issue #9071: [Feature] SkyWalking Python agent auto-startup in prefork servers

jiang1997 commented on issue #9071:
URL: https://github.com/apache/skywalking/issues/9071#issuecomment-1308857658

   # Case
   https://skywalking.apache.org/docs/skywalking-python/next/en/setup/faq/how-to-use-with-uwsgi/
   But start the application by cli as showd below
   ```
   sw-python uwsgi --die-on-term \
       --http 0.0.0.0:5000 \
       --http-manage-expect \
       --master --workers 3 \
       --enable-threads \
       --threads 3 \
       --manage-script-name \
       --mount /=main:app
   ```
   I've done a small amount of research, and this might be caused by the inherent property of Linux's ``fork``.
   In Python Agent, we use a global variable [_started](https://github.com/apache/skywalking-python/blob/11a74be39b07d55290c2df3de2b499bb126de048/skywalking/agent/__init__.py#L39) to prevent redundant initialization. 
   
   In preforking mode of ``uWsgi``, 
   1. ```uWsgi``` spawns a master process in which the Agent will be initialized for the first time and ``_started`` will be set as ``True``. 
   2. ```uWsgi``` spawns n worker processes in which ``_started`` remains ``True``. So the necessary reporting threads will not be created here and nothing will be sent to ``oap``.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org