tasks.py 297 B

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