tasks.py 272 B

12345678910111213
  1. import requests
  2. from celery import task
  3. @task()
  4. def urlopen(url):
  5. print('Opening: {0}'.format(url))
  6. try:
  7. response = requests.get(url)
  8. except Exception as exc:
  9. print('URL {0} gave error: {1!r}'.format(url, exc))
  10. return len(response.text)