tasks.py 354 B

1234567891011121314
  1. import requests
  2. from celery import task
  3. @task(ignore_result=True)
  4. def urlopen(url):
  5. print('Opening: {0}'.format(url))
  6. try:
  7. requests.get(url)
  8. except requests.exceptions.RequestException as exc:
  9. print('Exception for {0}: {1!r}'.format(url, exc))
  10. return url, 0
  11. print('Done with: {0}'.format(url))
  12. return url, 1