Python3 Asyncio implements an event loop, but in quite low level, it's missing some basic helpers that can make your life a lot easier.
The Pool and Group are typical missing ones. Compare these codes below
- without group
[ | |
{ | |
"label": "内网网关地址", | |
"name": "gateway", | |
"value": "10.86.30.1" | |
}, | |
{ | |
"label": "上班打卡时间范围", | |
"name": "clockInRange", | |
"value": "07:00-11:00" |
! function (t) { | |
if ("object" == typeof exports && "undefined" != typeof module) module.exports = t(); | |
else if ("function" == typeof define && define.amd) define([], t); | |
else { | |
("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).buffer = t() | |
} | |
}(function () { | |
return function () { | |
return function t(r, e, n) { | |
function i(f, u) { |
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:f7fc0e66200bb5a9cae8e5e59abfaa99691caa881252e9266f11e7cffc7dafe6" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
seeing this puzzle in glowing's jobs page
https://glowing.com/jobs/mobiledeveloper#mtop
here's my solution
import time | |
from collections import deque | |
def throttled_call(func, args=(), kwargs={}, threshold_per_minute=60): | |
"""Throttling the function call with ``threshold_per_minute`` calls per minute. | |
This is useful when the function request a remote service that having throttling policy. | |
We must honor the throttling, otherwise we will be banned. | |
:param func: the function to be called |
def chop(matrix, box, direction, results=None): | |
if results is None: | |
results = [] | |
x1, y1, x2, y2 = box | |
w = x2 - x1 + 1 | |
h = y2 - y1 + 1 | |
if w <= 0 or h <= 0: | |
return results | |
else: | |
if direction == 0: |
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |