Skip to content

Instantly share code, notes, and snippets.

@clayg
clayg / bench_get_namespaces.py
Last active January 10, 2024 16:35
Sqlite has a feature to allow custom sort order: https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.create_collation We might find that advantagous to use it when ordering rows from the shard_range table.
View bench_get_namespaces.py
#!/usr/bin/env python
import argparse
import sys
import timeit
from swift.common.utils import Namespace
from swift.container.backend import ContainerBroker
parser = argparse.ArgumentParser()
parser.add_argument('path', help='path to the .db')
@clayg
clayg / logging_locks.py
Created April 20, 2022 17:00
See if green_existing_locks works?
View logging_locks.py
import logging
import eventlet.patcher
eventlet.patcher.monkey_patch(thread=True)
import threading
def take_and_release():
try:
logging._lock.acquire()
finally:
View gist:1052fb8ffebf07525ace9c47aa02f572
vagrant@saio:~$ curl http://127.0.0.4:6041/sdb4/47/AUTH_test/container-6fb8e61f-f131-4037-9219-83c400ba81e7 -v
* Trying 127.0.0.4:6041...
* TCP_NODELAY set
* Connected to 127.0.0.4 (127.0.0.4) port 6041 (#0)
> GET /sdb4/47/AUTH_test/container-6fb8e61f-f131-4037-9219-83c400ba81e7 HTTP/1.1
> Host: 127.0.0.4:6041
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
@clayg
clayg / async_pending_stats.py
Last active October 5, 2022 18:16
Get info about async pendings
View async_pending_stats.py
#!/usr/bin/env python
import sys
import os
import errno
from argparse import ArgumentParser
from collections import defaultdict
import pickle
import logging
try:
import thread
@clayg
clayg / traceback.out
Created March 23, 2021 18:20
asyncio grpc & KeyboardInterrupt
View traceback.out
grpc/examples/python/helloworld$ python async_greeter_server.py
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:grpc._cython.cygrpc:Using AsyncIOEngine.POLLER as I/O engine
INFO:root:Starting server on [::]:50051
^CDEBUG:grpc._cython.cygrpc:__dealloc__ called on running server <grpc._cython.cygrpc.AioServer object at 0x7f49685adc10> with status 4
Traceback (most recent call last):
File "async_greeter_server.py", line 50, in <module>
asyncio.run(serve())
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
@clayg
clayg / s3_create_bucket.py
Created January 22, 2021 22:03
send extra headers to s3
View s3_create_bucket.py
#!/usr/bin/env python
from argparse import ArgumentParser
import sys
import json
import boto3
parser = ArgumentParser()
parser.add_argument('bucket', help='Bucket to make')
@clayg
clayg / test_iter.py
Last active November 19, 2020 18:51
i have no idea what i'm doing
View test_iter.py
from swift.common.utils import Watchdog, WatchdogTimeout, GreenAsyncPile
from eventlet.greenthread import spawn
from eventlet import sleep, Timeout
import random
watchdog = Watchdog()
watchdog.spawn()
def range_iter(start=0):
@clayg
clayg / check_memcache.py
Created November 17, 2020 23:26
poke at local dev memcache
View check_memcache.py
#!/usr/bin/env python
from argparse import ArgumentParser
import json
from swift.common.memcached import MemcacheRing
from swift.proxy.controllers.base import get_cache_key
import sys
parser = ArgumentParser()
parser.add_argument('container', help='Name of container to check')
@clayg
clayg / slow_s3_download.py
Created November 11, 2020 17:44
s3 client for playing with slow ranged reads
View slow_s3_download.py
from argparse import ArgumentParser
import sys
import time
import boto3
parser = ArgumentParser()
parser.add_argument('bucket', help='bucket to make the upload')
parser.add_argument('key', nargs='?', help='key name for large object')
@clayg
clayg / healthcheck_stats.py
Last active October 9, 2020 23:35
keep an eye on things
View healthcheck_stats.py
import sys
import subprocess
from swift.common.utils import get_logger
from threading import Thread
import time
import socket
import os
import ssl