This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals, print_function | |
import random | |
def random_list(start=1, stop=1001, length=1000): | |
if stop <= length: | |
raise ValueError('stop value must be greater than length') | |
else: | |
return random.sample(xrange(start,stop), length) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ways of handling file download using Requests library | |
import contextlib | |
import os | |
import requests | |
def download_file(url, dest_dir): | |
# reassurance that the connection will be closed: | |
# Requests cannot release the connection back to the pool unless you consume all the data or call Response.close | |
with contextlib.closing(requests.get(url=url, stream=True)) as response: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Safe Queue Celery App Settings | |
from __future__ import absolute_import, unicode_literals | |
from celery import Celery | |
app = Celery('some_project', | |
broker='amqp://', | |
backend='amqp://', | |
include=['some_project.tasks']) |