File: tasks.py

package info (click to toggle)
celery 5.6.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,572 kB
  • sloc: python: 66,917; sh: 795; makefile: 378
file content (14 lines) | stat: -rw-r--r-- 306 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import requests

from celery import shared_task


@shared_task()
def urlopen(url):
    print(f'-open: {url}')
    try:
        response = requests.get(url)
    except requests.exceptions.RequestException as exc:
        print(f'-url {url} gave error: {exc!r}')
        return
    return len(response.text)