File: tasks.py

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

from celery import task


@task(ignore_result=True)
def urlopen(url):
    print(f'Opening: {url}')
    try:
        requests.get(url)
    except requests.exceptions.RequestException as exc:
        print(f'Exception for {url}: {exc!r}')
        return url, 0
    print(f'Done with: {url}')
    return url, 1