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 2021/10/20 11:25:37 UTC

[GitHub] [skywalking-python] tom-pytel edited a comment on pull request #167: Cleanup and Python 3.10 support

tom-pytel edited a comment on pull request #167:
URL: https://github.com/apache/skywalking-python/pull/167#issuecomment-947572463


   The celery server does not support grpc because it forks server processes and grpc is not good with that so you will need to use the agent http protocol.
   
   Server script:
   ```py
   #!/usr/bin/env python3
   
   # docker run --name=redis-devel --publish=6379:6379 --hostname=redis --restart=on-failure --detach redis:latest
   # celery -A t_celery worker -l info
   
   from celery import Celery
   from time import sleep
   
   from skywalking import agent
   agent.start()
   
   app = Celery('test', broker = 'redis://localhost:6379', backend = 'redis://localhost:6379')
   
   @app.task
   def reverse(text):
       sleep(1)
       return text[::-1]
   ```
   Setup:
   ```
   pip install redis celery "apache-skywalking[http]"
   export SW_AGENT_PROTOCOL=http
   export SW_AGENT_COLLECTOR_BACKEND_SERVICES="127.0.0.1:12800"
   docker run --name=redis-devel --publish=6379:6379 --hostname=redis --restart=on-failure --detach redis:latest
   celery -A t_celery worker -l info
   ```
   In the same directory as the client (notice it imports the server module):
   ```py
   #!/usr/bin/env python3
   
   from skywalking import agent
   agent.start()
   
   import t_celery
   
   print(t_celery.reverse.delay('ABC'))
   print(t_celery.reverse('ABC'))
   print(t_celery.reverse.apply_async(('ABC',)))
   print(t_celery.reverse.apply(('ABC',)))
   ```
   In the same directory but another terminal:
   ```
   export SW_AGENT_PROTOCOL=http
   export SW_AGENT_COLLECTOR_BACKEND_SERVICES="127.0.0.1:12800"
   ./t_celery_client.py
   ```
   The final status of the jobs may not be instantaneous to update on the oap server, but all the exit celery requests should connect to to entry requests (except one spurious Local call which I just noticed but don't have time to track down where it came from right now).
   
    NOTE: Ignore the redis stuff, or just disable the plugin, all you care about is the celery stuff.


-- 
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