This file contains 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
import pickle as _pickle | |
import json | |
from functools import partial | |
class pickle: | |
dumps = partial(_pickle.dumps, protocol=_pickle.HIGHEST_PROTOCOL) | |
loads = _pickle.loads | |
This file contains 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
import redis | |
from time import sleep | |
from random import randint | |
from redq import RedisDeque | |
r = redis.StrictRedis() | |
q = RedisDeque(r, "l") | |
def consumer(): | |
while True: |
This file contains 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
import asyncio | |
from concurrent.futures import ProcessPoolExecutor | |
import aiohttp | |
from loguru import logger as loguru | |
from lxml.html import fromstring | |
pool = ProcessPoolExecutor() | |
parser_sem = asyncio.Semaphore(pool._max_workers) |
This file contains 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
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"regexp" | |
"strings" |
This file contains 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
class Semaphore { | |
constructor(max = 1) { | |
if (max < 1) { max = 1; } | |
this.max = max; | |
this.count = 0; | |
this.queue = []; | |
} | |
acquire() { | |
let promise; | |
if (this.count < this.max) { |
OlderNewer