Do: pip install -r requirements.txt
Do: python taskqueue.py
You will need a service file. Amend the location in the entry point in taskqueue.py.
| import asyncio | |
| import time | |
| from pools import threads, processes | |
| in_thread = threads(10) | |
| in_process = processes(4) | |
| def fib(n): |
Do: pip install -r requirements.txt
Do: python taskqueue.py
You will need a service file. Amend the location in the entry point in taskqueue.py.
pip install elasticsearch
Read https://elasticsearch-py.readthedocs.io/en/master/
Read example_es.py. :)
| apt-get update | |
| apt-get install -y \ | |
| apt-transport-https \ | |
| ca-certificates \ | |
| curl \ | |
| gnupg2 \ | |
| software-properties-common | |
| curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - |
NGINX conf:
# limit_req_zone $request_uri zone=per_uri_2s:10m rate=30r/m;
limit_req_zone $limit_post zone=per_uri:10m rate=30r/m;
limit_req_status 429;
location ~ ^/v\d+/tasks/.*/claim$ {
limit_req zone=per_uri_2s;
[...]
| #!/bin/bash | |
| # BEGIN SANITY BOX------------------------------------------ | |
| set -e # immediately exit if any command fails | | |
| set -u # immediately fail on undefined variables | | |
| set -o pipefail # show error of last failed command | | |
| IFS=$'\n\t' # control what word splitting means | | |
| # END SANITY BOX-------------------------------------------- | |
| # delete |
| // THIS WILL NOT WORK UNTIL NODE implements `Atomics` :) Soon? | |
| const readline = require('readline'); | |
| const rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout | |
| }); | |
| function msleep(n) { |
| const v8 = require('v8') | |
| const iterations = 1000 | |
| const getData = () => { | |
| // return a large data blob | |
| return [ | |
| { |
| # fire-n-forget | |
| # | |
| # https://bugs.python.org/issue44665 | |
| # https://bugs.python.org/issue42538 | |
| import asyncio | |
| import functools | |
| running_tasks = set() |
| cases = [ | |
| ([], 0), | |
| ([10], 0), | |
| ([1, 2, 3, 4], 0), | |
| ([1, 1, 1, 1], 6), | |
| ([1, 3, 2, 1], 3), | |
| ([1, 7, 1, 4], 13), | |
| ] | |