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
# ------------------------------------------------ | |
# イベントループを別スレッドで動作させて | |
# メインスレッドは生かすサンプル | |
# | |
# asyncio をつかった処理にて、別スレッドから | |
# イベントスレッドに対して処理を行う場合 | |
# イベントスレッド自体がスレッドセーフではないため | |
# 専用のメソッドを利用する必要がある | |
# | |
# - ev_loop.call_soon_threadsafe() |
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
""" | |
This gist shows how to run asyncio loop in a separate thread. | |
It could be useful if you want to mix sync and async code together. | |
Python 3.7+ | |
""" | |
import asyncio | |
from datetime import datetime | |
from threading import Thread | |
from typing import Tuple, List, Iterable |
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 | |
import threading | |
import random | |
import time | |
async def coro(n, name): | |
for i in range(n): | |
sleep_time = random.uniform(.3, .7) | |
print('coro({0}) [{1}/{2}] -> sleep_time {3:.2f}'.format(name, i, n, sleep_time), flush=True) | |
await asyncio.sleep(sleep_time) |
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
#!/bin/bash | |
# | |
# Ubuntu安装并配置aria2 | |
# | |
# @Author: Jaeger <JaegerCode@gmail.com> | |
# @Version: 0.1 | |
#配置文件下载保存路径 | |
downloadPath='/user-files/superuser/dl' |
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 pandas as pd | |
import itertools | |
import time | |
import multiprocessing | |
from typing import Callable, Tuple, Union | |
def groupby_parallel( | |
groupby_df: pd.core.groupby.DataFrameGroupBy, | |
func: Callable[[Tuple[str, pd.DataFrame]], Union[pd.DataFrame, pd.Series]], | |
num_cpus: int = multiprocessing.cpu_count() - 1, |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>KeepAlive</key> | |
<true/> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>Label</key> | |
<string>homebrew.mxcl.aria2</string> |
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
continue | |
dir=/var/www/downloads | |
file-allocation=falloc | |
max-connection-per-server=4 | |
max-concurrent-downloads=2 | |
max-overall-download-limit=0 | |
min-split-size=25M | |
rpc-allow-origin-all=true | |
rpc-secret=YouShouldChangeThis | |
input-file=/var/tmp/aria2c.session |