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
select pid, | |
usename, | |
pg_blocking_pids(pid) as blocked_by, | |
query as blocked_query | |
from pg_stat_activity | |
where cardinality(pg_blocking_pids(pid)) > 0; |
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 logging | |
from asyncio import AbstractEventLoop | |
from concurrent.futures import Future | |
from threading import Thread | |
from typing import Coroutine | |
from app.common.logger import logger | |
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 org.monocle; | |
import java.io.IOException; | |
import org.apache.flink.api.common.state.ValueState; | |
import org.apache.flink.api.common.state.ValueStateDescriptor; | |
import org.apache.flink.streaming.api.windowing.time.Time; | |
import org.apache.flink.configuration.Configuration; | |
import org.apache.flink.util.Collector; | |
import org.apache.flink.streaming.api.functions.KeyedProcessFunction; |
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 boto3 | |
import os | |
import time | |
from subprocess import Popen, PIPE | |
import pyarrow.parquet as pq | |
import pickle | |
import hashlib | |
TSDB_CPUS = 8 |
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
def to_asyncio_in_thread(func): | |
async def wrapper(*args, **kwargs): | |
return await asyncio.get_event_loop().run_in_executor(None, lambda: func(*args, **kwargs)) | |
return wrapper | |
# Usage: | |
@to_asyncio_in_thread |
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
from cachetools import TTLCache | |
from cachetools.keys import hashkey | |
from parameterized_lock import parameterized_lock | |
def async_threadsafe_ttl_cache(func=None, ttl=60): | |
cache = TTLCache(maxsize=100, ttl=ttl) | |
def decorator(decorated_func): |
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 cProfile | |
import io | |
import pstats | |
pr = cProfile.Profile() | |
pr.enable() | |
### Code to profile here | |
pr.disable() | |
s = io.StringIO() | |
ps = pstats.Stats(pr, stream=s).sort_stats('time') |